ASP.NET LisItem Attributes.Add does not work
Posted on 2004-08-03
I am binding a datasource to a CheckBoxList, and in the list of options I have a "None of these Apply to me" option, which is drawn from the datasource (i.e. so no, I cannot simply add a separate checkbox to do this, it must be implemented in the checkboxlist). What i tried to do is the following:
** the variable 'List' is the CheckBoxList
private override void OnPreRender(EventArgs e)
//since the N/A option is always last
ListItem na = List.Items[List.Items.Count - 1];
--the onclick attribute is never added..this works flawlessly with a separate checkbox, why does the Attributes.Add method never work with ListItems?? This is extremely annoying, I can't understand why this would not have been implemented for listitems.