User-284642143 posted
I have two controls, a radiobuttonList and CheckboxList. I would like to retrieve the items selected within these controls.
private void ItemsInList(object c)
{
if (c == typeof(RadioButtonList))
{
}
else if (c == typeof(CheckBoxList))
{
}
foreach (ListItem li in c.Items)
{
}
}
What i'm trying to do is pass in a control (c) and then determine if its a RBL or CBL (if i need to that is) and then iterate through the list and take some action.
At present i have the above code but receive the error
'object' does not contain a definition for 'Items' and no extension method 'Items' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?
Im not entirely sure if this is possible or if im doing something wrong?