Pindub_Amateur Pindub_Amateur - 13 days ago 4x
ASP.NET (C#) Question

item.Selected is false when the checkboxlist is disabled.

I have a checkboxlist where certain items are disabled for certain users.

enter image description here

When I click on 'Save', the below code is executed.

foreach (ListItem item in myCheckBoxList.Items)
if (!item.Selected)

However, item.Selected evaluates to false for the disabled items even though they're selected.

Is there a way to get around this?


Disabled inputs are never posted to the server, hence it will be set to default value, i.e. false. You can use HiddenField and associate that with each checkbox and set it's value based on it's selection.