> I'm using Andy Smith's RowSelectorColumn control (great control) and I'm
not
sure if this question is generic to all datagrid controls or this
particular one.
Is there a way to disable one of the checkboxes based on data in the
grid? If so, can you provide the syntax?
If you need to take some action for a DataGrid based on the data in the
row, you need to create an event handler for the DataGrid's ItemDataBound
event. There you can check the data, programmatically reference the
checkbox, and then, based on the data, fiddle with the checkbox (or
whatever Web control in the row you're interested in).
** IN THE DATAGRID'S ITEMDATABOUND EVENT HANDLER... **
If e.Item.ItemType = ListItemType.Item or e.Item.ItemType =
ListItemType.AlternatingItem then
'Reference the RowSelectorColumn checkbox (note, it is an
HtmlInputCheckBox class instance,
'and NOT a CheckBox class instance
Dim myCB As HtmlInputCheckBox =
CType(e.Item.Cells(CELLINDEX).Controls(0), HtmlInputCheckBox)
'Check the data
Dim someColumnValue as String = CType(DataBinder.Eval(e.Item.DataItem,
"SomeColumnName"), String)
If someColumnValue = "someValue" then
myCB.Enabled = False
End If
End If
Hope this helps! Also you might find my book, ASP.NET Data Web Controls
Kick Start to be of interest in amassing further knowledge about the
DataGrid, DataList, and Repeater Web controls.
Happy Programming!
--
<shameless plug>
For more information on the DataGrid, DataList, and Repeater controls,
consider picking up a copy of my latest book:
ASP.NET Data Web Controls
http://www.amazon.com/exec/obidos/AS...uysfromrollaco
</shameless plug>
Happy Programming!
Scott Mitchell
mi******@4guysfromrolla.com http://www.4GuysFromRolla.com http://www.ASPFAQs.com http://www.ASPMessageboard.com
* When you think ASP, think 4GuysFromRolla.com!