Hi,
I am trying to build a datagrid dynamically and adding columns by looping
through a recordset of column names. One of the columns is a bit in SQL server
and I know you can have a checkbox display as checked based on the bit value if
you are doing a straight forward dataset bind. But my problem is, What "typeof"
column do I need to be adding to my datatable for this "bit" column so that the
checkbox reads the value correctly? Here's the error I am getting:
System.FormatException: String was not recognized as a valid Boolean. at
System.Boolean.Parse(String value) at System.Convert.ToBoolean(String value,
IFormatProvider provider) at
System.String.System.IConvertible.ToBoolean(IFormatProvider provider) at
System.Convert.ToBoolean(Object value) at
System.Data.Common.BooleanStorage.Set(Int32 record, Object value) at
System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't store <1>
in Active Column. Expected type is Boolean.
Here's my column add statement:
//Value of Header is "Active"
dataTable.Columns.Add(dataRowColumn["Header"].ToString(), typeof(bool));
Here's my datagrid item template:
<ItemTemplate>
<asp:CheckBox ID="Checkbox1" runat="server"
Checked='<%#DataBinder.Eval(Container.DataItem, "Active")%>'></asp:CheckBox>
</ItemTemplate>
Thanks,
Jim
---------------------------------
Yahoo! FareChase - Search multiple travel sites in one click.
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/