gridview with checkbox ?

Discussion in 'ASP .Net' started by Jarod, Jan 17, 2006.

  1. Jarod

    Jarod Guest

    Hey
    I have gridView with a checkbox and I bind it to a dataset. In dataset is a
    column called "Assigned" and it contains 0 or 1. When I tried to bound it I
    got error and I check in details that there is no way to convert string to
    boolean. So how to force him to convert it ?
    Jarod
    Jarod, Jan 17, 2006
    #1
    1. Advertising

  2. Jarod,

    Use ItemDataBound event to do something like (metacode):

    myCheckBox.Checked = (value of column "Assigned" == 1)

    Eliyahu

    "Jarod" <> wrote in message
    news:...
    > Hey
    > I have gridView with a checkbox and I bind it to a dataset. In dataset is
    > a column called "Assigned" and it contains 0 or 1. When I tried to bound
    > it I got error and I check in details that there is no way to convert
    > string to boolean. So how to force him to convert it ?
    > Jarod
    Eliyahu Goldin, Jan 17, 2006
    #2
    1. Advertising

  3. Jarod

    Jarod Guest

    > Use ItemDataBound event to do something like (metacode):
    >

    The problem is there is nothing like ItemDataBound event :(
    I mean GridView not a dataGrid.
    Jarod
    Jarod, Jan 17, 2006
    #3
  4. RowDataBound

    Eliyahu

    "Jarod" <> wrote in message
    news:%23%...
    >> Use ItemDataBound event to do something like (metacode):
    >>

    > The problem is there is nothing like ItemDataBound event :( I mean
    > GridView not a dataGrid. Jarod
    Eliyahu Goldin, Jan 17, 2006
    #4
  5. Jarod

    Jarod Guest

    > RowDataBound
    >


    RowDataBound is fired after binding. So if there is a wrong data to bound
    you will get error before event.
    Jarod
    Jarod, Jan 17, 2006
    #5
  6. Jarod,

    You don't have to bind to wrong data. Leave the checkbox unbound and just
    set it's Checked property in the event.

    Eliyahu

    "Jarod" <> wrote in message
    news:%...
    >> RowDataBound
    >>

    >
    > RowDataBound is fired after binding. So if there is a wrong data to bound
    > you will get error before event.
    > Jarod
    Eliyahu Goldin, Jan 17, 2006
    #6
  7. Jarod

    Jarod Guest

    > You don't have to bind to wrong data. Leave the checkbox unbound and just
    > set it's Checked property in the event.
    >


    If you don't bind you won't have data. In the RowDataBound event you can
    take data from the bounded control if you didn't bind you won't have any
    data. Maybe you can share some code to show what you mean ?
    Jarod
    Jarod, Jan 17, 2006
    #7
  8. I mean you do bind the GridView, i.e. do set the DataSource and DataMember
    property and call the DataBind method. But don't bind the checkbox control,
    i.e. don't set the Checked property with a databind expression.

    Eliyahu

    "Jarod" <> wrote in message
    news:%...
    >> You don't have to bind to wrong data. Leave the checkbox unbound and just
    >> set it's Checked property in the event.
    >>

    >
    > If you don't bind you won't have data. In the RowDataBound event you can
    > take data from the bounded control if you didn't bind you won't have any
    > data. Maybe you can share some code to show what you mean ?
    > Jarod
    Eliyahu Goldin, Jan 18, 2006
    #8
    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:
    504
    tshad
    Apr 15, 2005
  2. Vikram

    disable checkbox list checkbox

    Vikram, Jan 25, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,376
    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:
    799
    David Wier
    Oct 6, 2006
  4. Jason Huang
    Replies:
    0
    Views:
    538
    Jason Huang
    Jun 29, 2007
  5. Joey Pang
    Replies:
    4
    Views:
    504
    Joey Pang
    Jun 13, 2005
Loading...

Share This Page