Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Checkbox binding in datagrid? (http://www.velocityreviews.com/forums/t112032-checkbox-binding-in-datagrid.html)

=?Utf-8?B?RGF2ZQ==?= 10-20-2005 06:33 PM

Checkbox binding in datagrid?
 
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>

Sebastian Wojciechowski 10-20-2005 08:56 PM

Re: Checkbox binding in datagrid?
 

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" <Dave@discussions.microsoft.com> wrote in message
news:5F2B38D1-3A96-4DAE-A168-340991318245@microsoft.com...
> 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>





All times are GMT. The time now is 10:37 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.