How do I check whether a DropDownList is initialized in ASP.NET? I’m not talking about checking for empty strings. The dropdownlist is usually unintialized if there the datasource was not bound to it. So when I try to check the contents with something like this
x = DropDownList.SelectedItem.ToString()
it simply bombs…any suggestions?
You can check if the list has items:
If it’s initialized it’ll have items, if not it wont throw an error.