Reset checkboxes in datalist on click of button that is outside of datalist using c#
views:
1086answers:
2
A:
In the eventhandler for the buttons OnClick event you'd loop trough each item in the datalist and find the checkbox and reset it.
Sani Huttunen
2009-02-19 07:29:29
foreach (DataListItem item in DataList1){ }when i try like this it shows error. Plz provide me the source code.thanks
Yogini
2009-02-19 07:36:54
you should use foreach(DataListItem item in DataList1.Items){}
Sani Huttunen
2009-02-19 07:43:39
A:
What CKret said and also, I often find the Enumerable.OfType Method method very useful to do things like that. Looping through components of some type in a collection of some sort. For example, somewhere I do something like this:
foreach(CheckBox c in somePanel.Controls.OfType<CheckBox>())
{
c.Checked = false;
}
Svish
2009-02-19 07:36:46