thinking about CheckBoxList
I was thinking about the CheckBoxList control today, and
it hit me that while you can set the DataTextField and DataValueField
properties, a really useful one would be a DataSelectedField property, which
pointed to a boolean field in the row which indicated the Selected property of
the ListItem, which would translate to the Checked property of the checkbox.
To implement that, I'll probably have to subclass CheckBoxList and
reimplement DataBind. At first I thought I could just override it, and run thru
the datasource again, but then I thought about the scenario where people bind to
DataReaders, which can't be read thru twice. So I guess it's up to me to
reimplement the whole function.
What would have been useful is if the DataBind method seperated out the
itteration of the datasource, with the application of each item's
information. Something along the lines of a protected virtual method that got
passed one item from the enumeration and the ListItem to be affected.
I realize it wouldn't make much sense for the basic implementation of the
control, but it's really really usefull for somebody extending the control.
I'm thinking I might even make an event for this, so that others could even
more easily extend it to allow for setting colors or whatever based on the
ListItem and currently enumerated data object/row.