gridview with checkbox ?

  • Thread starter Thread starter Jarod
  • Start date Start date
J

Jarod

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,

Use ItemDataBound event to do something like (metacode):

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

Eliyahu
 
Use ItemDataBound event to do something like (metacode):The problem is there is nothing like ItemDataBound event :(
I mean GridView not a dataGrid.
Jarod
 
RowDataBound
RowDataBound is fired after binding. So if there is a wrong data to bound
you will get error before event.
Jarod
 
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
 
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
 
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
 
Back
Top