check for null dropdown in listview control

I am binding a listview control using linqdatasource.  Listview contains two cascading dropdown controls.  Category and sub category.  The "sub category" dropdown can be optional as some categories do not have subcategories.  So when inserting record that does not have a subcategory the subcategory is set to zero in the database.

How can I check when binding the subcategory dropdown if it is zero then either set a default option or disable the second dropdown.  

It is being bound to the data source like this

SelectedValue='<%# Bind("itemSubCategory") %>'
mugseyAsked:
Who is Participating?
 
Rupesh PConnect With a Mentor Commented:

Assuming that you are connecting to the database each and every time to get the subcategories of
selected category.

Suppose you are using the DropDownList1for caetgories and  DropDownList2for the subcategories.

use the DropDownList1_SelectedIndexChanged event to see whether the selected category having subcategory exists.
if not exists
   DropDownList2.Style.Add("display","none")
else
{
   Re bind the  DropDownList2 with teh subcategies corresopndign for the category.
   DropDownList2.Style.Add("display","block")
}


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.