Checkbox binding in datagrid?

Discussion in 'ASP .Net' started by =?Utf-8?B?RGF2ZQ==?=, Oct 20, 2005.

  1. 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>
     
    =?Utf-8?B?RGF2ZQ==?=, Oct 20, 2005
    #1
    1. Advertising

  2. 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:...
    > 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, Oct 20, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad
    Replies:
    0
    Views:
    532
    tshad
    Apr 15, 2005
  2. Vikram

    disable checkbox list checkbox

    Vikram, Jan 25, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,407
    ThunderMusic
    Jan 25, 2006
  3. =?Utf-8?B?RG90TmV0RGV2?=

    DataGrid and embeded Checkbox..How to find if checkbox clicked

    =?Utf-8?B?RG90TmV0RGV2?=, Oct 6, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    831
    David Wier
    Oct 6, 2006
  4. Jason Huang
    Replies:
    0
    Views:
    560
    Jason Huang
    Jun 29, 2007
  5. Joey Pang
    Replies:
    4
    Views:
    524
    Joey Pang
    Jun 13, 2005
Loading...

Share This Page