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
}
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
}`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With