Pindub_Amateur Pindub_Amateur - 1 year ago 69
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download