check for null dropdown in listview control

Posted on 2008-11-13
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
    LVL 3

    Accepted Solution


    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

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now