views:

193

answers:

1

I have a CheckBoxList in my page, with the DataTextField and DataValueField attributes set, is there an attribute that I can use to specify a property that indicates if it should be checked?

I'm hoping to just set the datasource, and not have to have any code behind to set the checked property. Possible?

+1  A: 

No it's not possible because the control uses the same binding as other controls such as ListBox, DropDownList, RadioButtonList, etc.

As per MSDN:

To set multiple selections in a list control programmatically loop through the control's Items collection and set the Selected property of every individual item.

You could implement the OnDataBinding of the CheckListBox and then do a lookup for each item that gets bound but it would probably just be easier to do it all in one place.

Kelsey