>> OK. What *precisely* is the value of "PL" out of the database, and what
>> is the datatype?
[quoted text clipped - 3 lines]
>>
> It is a varchar. The value is 0 or 1.
OK, well that's *never* going to work natively as you've already discovered.
> I tried a Convert.ToInt32, but receeved an error about the bool value. I
> don' t control the table structures and have to use what is given to me.
Hmm - OK... Where did you do the Convert.ToInt32?
> Shouldn' t an integer 1 or 0 be evaluated as a bool?
Yes it should - which is why I'm wondering where you did the conversion...

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
gh - 20 May 2008 15:48 GMT
>>> OK. What *precisely* is the value of "PL" out of the database, and
>>> what is the datatype?
[quoted text clipped - 16 lines]
>
> Yes it should - which is why I'm wondering where you did the conversion...
<asp:TemplateField>
<EditItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server"
Checked='<%# Convert.ToInt32(DataBinder.Eval(Container.DataItem, "PL"))
%>' />
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server"
Checked='<%# Convert.ToInt32(DataBinder.Eval(Container.DataItem, "PL"))
%>'
Enabled="false" />
</ItemTemplate>
Thanks
Mark Rae [MVP] - 20 May 2008 16:16 GMT
>> Yes it should - which is why I'm wondering where you did the
>> conversion...
[quoted text clipped - 11 lines]
> Enabled="false" />
> </ItemTemplate>
OK, indulge me...
Change the above to the code below, and tell me what the Text shows next to
the CheckBoxes...
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%#
DataBinder.Eval(Container.DataItem, "PL") %>' Enabled="false" />
</ItemTemplate>
</ asp:TemplateField>

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
Mark Rae [MVP] - 20 May 2008 16:23 GMT
> <asp:TemplateField>
> <ItemTemplate>
> <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%#
> DataBinder.Eval(Container.DataItem, "PL") %>' Enabled="false" />
> </ItemTemplate>
> </ asp:TemplateField>
Apologies - I meant this:
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "PL") %>' />
</ItemTemplate>
</ asp:TemplateField>

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
gh - 21 May 2008 12:32 GMT
>> <asp:TemplateField>
>> <ItemTemplate>
[quoted text clipped - 11 lines]
> </ItemTemplate>
> </ asp:TemplateField>
Mark:
I have it working using the suggested markup:
Checked='<%# DataBinder.Eval(Container.DataItem, "PL").ToString() ==
"1" %>'.
Thanks
as stated the "checked" value needs to be a bool. so:
Checked='<%# DataBinder.Eval(Container.DataItem, "PL").ToString() == "1" %>'
will work.
-- bruce (sqlwork.com)
> >>>> What could be causing the error?
> >>>
[quoted text clipped - 29 lines]
>
> Thanks