Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Checkbox binding in datagrid?

Reply
Thread Tools

Checkbox binding in datagrid?

 
 
=?Utf-8?B?RGF2ZQ==?=
Guest
Posts: n/a
 
      10-20-2005
Hi,

How do you set the checked property for checkbox column in a datagrid? The
SimpleYn is a bit column value in the database. When I try it, I'm getting a
cast error. Thanks.

<asp:TemplateColumn HeaderText="Sample">
<ItemTemplate>
<asp:CheckBox ID="Sample"
Checked='<%# DataBinder.Eval(Container.DataItem, "SampleYn")%>'
runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
 
Reply With Quote
 
 
 
 
Sebastian Wojciechowski
Guest
Posts: n/a
 
      10-20-2005

call a function there
try this
<asp:CheckBox ID="Sample" Checked='<%#
ToBool(DataBinder.Eval(Container.DataItem, "SampleYn")) %>' runat="server"
/>

and create function ToBool that will convert the bit value to bool. Or try
to onvert it inline Cnvert.ToBool(DataBinder.Eval(Container.DataItem,
"SampleYn")).

Hope this helps.

"Dave" <> wrote in message
news:5F2B38D1-3A96-4DAE-A168-...
> Hi,
>
> How do you set the checked property for checkbox column in a datagrid?
> The
> SimpleYn is a bit column value in the database. When I try it, I'm
> getting a
> cast error. Thanks.
>
> <asp:TemplateColumn HeaderText="Sample">
> <ItemTemplate>
> <asp:CheckBox ID="Sample"
> Checked='<%# DataBinder.Eval(Container.DataItem, "SampleYn")%>'
> runat="server" />
> </ItemTemplate>
> </asp:TemplateColumn>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASPNET CheckBox and a CheckBox in a TemplateField Jason Huang ASP .Net 0 06-29-2007 12:35 AM
DataGrid and embeded Checkbox..How to find if checkbox clicked =?Utf-8?B?RG90TmV0RGV2?= ASP .Net 1 10-06-2006 04:11 PM
disable checkbox list checkbox Vikram ASP .Net 1 01-25-2006 02:59 PM
Howto bind CheckBox to the datagrid/ Then update the database field when the checkbox is clicked. Joey Pang ASP .Net Datagrid Control 4 06-13-2005 02:29 AM
Text on Checkbox below the checkbox tshad ASP .Net 0 04-14-2005 11:26 PM



Advertisments