I have this CheckBoxList on a page:
Removing caused an issue in some old code I was working on. I was getting this error. Once I got that error I realized it was too risky of a change.
To fix this, I ended up extending CheckBoxList and overriding the Render method to add an additional attribute containing the value to each list item:
public class CheckBoxListExt : CheckBoxList
{
protected override void Render(HtmlTextWriter writer)
{
foreach (ListItem item in this.Items)
{
item.Attributes.Add("data-value", item.Value);
}
base.Render(writer);
}
}
This will render the data-value attribute on the outer span tag.