jookymaster
asked on
ASP.NET LisItem Attributes.Add does not work
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.Coun t - 1];
na.Attributes.Add("onclick ", "javascript:_doPostBack(// client id generated here));
}
--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.
** 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.Coun
na.Attributes.Add("onclick
}
--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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I hope they fix that and all the other little bugs, without making new ones. :) Good luck.
ASKER