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. Advertisements

  2. Jarod,

    Use ItemDataBound event to do something like (metacode):

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

    Eliyahu
     
    Eliyahu Goldin, Jan 17, 2006
    #2
    1. Advertisements

  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

     
    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
     
    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
    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
     
    Eliyahu Goldin, Jan 18, 2006
    #8
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.