• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:


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  

  • 3
  • 3
1 Solution
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
Kumaraswamy RCommented:
set the property [drop down] - appendDataBoundItems=false

VBdotnet2005Author Commented:
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.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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%!
VBdotnet2005Author Commented:
"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.
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.
VBdotnet2005Author Commented:
could you provide a sample code?

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now