I have two related DropDownList controls. Depending on the selection in the parent DropDownList, I want to hide some items in the child DropDownList in case they were not related to the selected item in the parent DropDownList.
I was trying something along the lines of:
foreach(ListItem item in ddlChildren.Items)
{
item.Visible = /* some logic here */
}
However the Visible property doesn’t seem to be available here.
Could someone please suggest how I would go about achieving this functionality?
You cannot ‘hide’ values. You need to rebind or refill your list from scratch.
Optionally if you just want to remove specific ones you can remove or add but that is usually way more work than just rebuilding the list.