Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable specific items in a CheckboxList

I am running through a set of data, which will populate a CheckBoxList. I want to display all the items in the list but certain ones will be disabled as they don't qualify (their status equals Inactive). How do I set an item to disabled (Enabled = false) in the code behind like this?

if (node.SelectSingleNode("Status") == "Inactive")
   {
     customerList.Items.Add(new ListItem(displayName, displayValue)); // DISABLED
   }
else
   {
     customerList.Items.Add(new ListItem(displayName, displayValue));  // ENABLED
   }
like image 577
techora Avatar asked Feb 10 '23 23:02

techora


1 Answers

if (node.SelectSingleNode("Status") == "Inactive")
   {
     customerList.Items.Add(new ListItem{Name=displayName, Value= displayValue, Enabled= false}); // DISABLED
   }
else
   {
     customerList.Items.Add(new ListItem(displayName, displayValue));  // ENABLED
   }`
like image 81
JamesCarters Avatar answered Feb 13 '23 21:02

JamesCarters