Easy one.
I added programatically a few items to a radiuo button list:
foreach (var item in res)
{
rbl.Items.Add(new ListItem(item.text, item.value.ToString()));
}
After a change of view (Multiview), I need to come back to the view with the radio button list, but this view added again the items.
How can I reset the items already added to the radio button list?
Used, and not working:
rbl.ClearSelection()
rbl.Datasource = null;
rbl.DataBind();
rbl = new RadioButtonList();
Thanks.
The "ClearSelection()" method simply puts the selection to be "-1", in order to remove the data in the list you will need
RadioButtonList1.Items.Clear();
Also be careful, where you actually add the items, that might cause a problem as well, since I cannot see additional code it is just my prediction.
Hope this solves your problem. Cheers!