[Last Call] Learn how to a build a cloud-first strategyRegister Now


check for null dropdown in listview control

Posted on 2008-11-13
Medium Priority
Last Modified: 2012-05-05
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") %>'
Question by:mugsey
1 Comment

Accepted Solution

Rupesh P earned 2000 total points
ID: 22948630

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
   Re bind the  DropDownList2 with teh subcategies corresopndign for the category.


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Loops Section Overview
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month17 days, 18 hours left to enroll

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question