gridview with checkbox ?

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
 
E

Eliyahu Goldin

Jarod,

Use ItemDataBound event to do something like (metacode):

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

Eliyahu
 
J

Jarod

Use ItemDataBound event to do something like (metacode):The problem is there is nothing like ItemDataBound event :(
I mean GridView not a dataGrid.
Jarod
 
J

Jarod

RowDataBound
RowDataBound is fired after binding. So if there is a wrong data to bound
you will get error before event.
Jarod
 
E

Eliyahu Goldin

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
 
J

Jarod

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
 
E

Eliyahu Goldin

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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top