c# - Binding DropDownList's SelectedIndex to 0 if value does not exist -


I have a DropDownList in a DetailsView, which binds a user's 'allocated user' in the table. Occasionally, we have some accidents in the database, where the user is not in the allocated user table, which is filled with the dropdown list. In this case the site crashes and we do not exist in the list of 'selected value items'.

What I have to do, is to catch any compulsive errors like this, and just set the dropdownlight index 0. I have tried to do something like this:

  OnDataBinding = 'DoesExist ("Allocated User", )   

But it does not like that syntax any Other Thoughts?

Your question is usually asked repeatedly, in fact no old person can get anything Select 0 if the null is good with the database, or similar, but it is the one that should help in any way ...



Comments