I have a dropdownlist which has several options for generating reports. Based on the type of account the user has certain options which should be visible but not selectable
Adam Fox is absolutely correct with this snippet:
foreach ( ListItem item in dropdownlist.Items )
{
if ( [item should be disabled condition] )
{
item.Attributes.Add( "disabled", "disabled" );
}
}
The only caveat is that it needs to be called in the OnDataBound event, and not the OnDataBinding event (this is too early in the lifecycle).