Click here to Skip to main content
15,895,740 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello guys, I have a gridview with dropdown lists in them. I want the selected value from the dropdownlist to not appear in the next dropdown list.

How can I go about this problem. Links to code and suggestions are most welcome.

Eg : Suppose I have a drop down list for Cities. If I select 'Mumbai' from the first drop down list then 'Mumbai' should not appear in the next drop down list.
Posted
Comments
[no name] 27-Nov-12 9:33am    
Make sure that your datasource has event and when the column changes do a validation on that column in your datasources update.
samrat399 27-Nov-12 12:15pm    
no, i have the drop down in the same column, how to do that
[no name] 27-Nov-12 12:23pm    
Are you using a datatable? If you are then datatables have events, specifically the column changed event, then you can llop through the values of the column to make sure that each one is unique.

1 solution

If you are using data tables then you can use the column changed event, if someone changes the dropdown in the data grid, it updates the data table.

You can do a for loop inside the event handler to check to see if the value is unique and change any values that are not unique.

Click the link for a list of datatable events and sample code:-

http://msdn.microsoft.com/en-us/library/9hx67se8(v=vs.100).aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900