Posted on 2011-05-11
Last Modified: 2012-06-27
I have dropdownlists which items are generated using SQLDataSource.
values are in each dropdownlist below. There are 15 dropdownlists totals.  When users select account, can they next 5 rebind without account. Or whichever value selected, it should be removed from the controls. The reason is that I don't want users to checks duplicate values from dropdownlist.

order by  

Question by:VBdotnet2005
    LVL 4

    Expert Comment

    Your question is very unclear, but still, from my guess, you solution should be implemented as:

    The application is started.
    Initial data is bound (as described in section Data Fetching and Binding)!

    CODE SECTION: Item Selection:
    When an item is selected in a DropDown, store the selected item in a separate List which you will use in the "Data Fetching and Binding" section.

    Whenever a selection is done, the above "ITEM SELECTION" code needs to run.

    CODE SECTION: Data Fetching and Binding:
    1. Get Data from Database, after checking the required conditions. Store this in a list.
    2. Remove the items already selected.
    3. Databind to the DropDownList
    LVL 29

    Expert Comment

    by:Kumaraswamy R
    set the property [drop down] - appendDataBoundItems=false


    Author Comment

    all dropdownlist are in contentplaceholder.
    I have to loop thro page through controls, my mistake,l do not know in advace the total of dropdownlist.
    I use this to find them
    .findcontrol("Dropdownlist", & i), dropdownlist.datasource = sqldatasource1
    .findcontrol("Dropdownlist", & i), dropdownlist.datasource = "columnname"
    This is on pageload. So they are alreay binded to dropdownlist. My main reason that to prevent users from selecting duplicate values. Is there a better way to doing so. Or any controls out there that does such? Sorry, I am not clear here.
    LVL 4

    Expert Comment

    one way to do is to SAVE the selected values in a List<String>.
    When a user selects a value, check in the LIST, if the value exists, do not select, give a message to the user.
    If the value does not exist, save it to the list.

    Since you bind the controls only once, this will work always, it may not be the best way to do it, but will work 100%!

    Author Comment

    "When a user selects a value, check in the LIST, if the value exists, do not select, give a message to the user."

    Since it bind only one time on pageload, do you mean to check when a user click submit and loop through all drowdownlists? I am not sure what you meant.
    LVL 4

    Accepted Solution

    Yes, check the value after selection.

    Define an event-handler for selection of an item in DropDownList.
    And here, check in the LIST<> of selected item for that dropdown list.

    Author Comment

    could you provide a sample code?

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    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…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    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

    18 Experts available now in Live!

    Get 1:1 Help Now