1
Answer

How to prevent a datacolumn of gridview displaying null

amadobson

amadobson

21y
2.2k
1
Hi I am in my 2nd week of c# .net and I have a datagrid which has a datasource set to a datatable I retrieved from a SQL database. I added a datacolumn to the datasource called "Selected" as a boolean which is the only column the user can change. ie. A tick box has appeared for each row and the user can select / de-select the row The only problem is the user can select the DBNull state. I have disabled this in the definition of the datacolumn but I don't want the user to even be able to set it to null (grayed tick) Can anyone point me in the right direction Cheers Alan :-)
Answers (1)
0
dip_2004_05

dip_2004_05

NA 82 0 21y
Alan, Set the ThreeState property of the checkbox to false. You might need to make some changes.. Set AutoGenerateColumns for the datagrid to false. define the datagrid columns. Create a TemplateColumn for the boolean column. Set the ThreeState Property of the checkbox defined in the Template to false. There may be other easier/shorter ways to do the same thing .. - dip