0
votes

I have a question about C#. I have a Access database table like following

|------------| --------- | ------------ |
|  Car Type  | Car Color | Max Car Size |
|------------|  ---------| ------------ |
|      1     |   Yellow  |      10      |
|      1     |    Red    |       9      |
|      1     |    Blue   |       8      |
|      2     |   Yellow  |      20      |
|      2     |   Green   |       9      |
|------------| --------- | ------------ |

I want to display the data in 3 drop down lists. I use the GridView, Itemtemplate to add 3 columns and all of them have 'drop down list' ithem.

I want the each of the drop down list has the depending function. It means that

Drop Down List

  1. Select '1' in drop down list 1 (The drop down list 2 will display 'Yellow', 'Red', Blue')
  2. Select 'Blue' in drop down list 2 (The drop down list 3 will display '1-8')

If the user select '2' in drop down list 1, drop down list two will select nothing.

What should I do? Can I add the SqlDataSource to do it?

1
What UI library are you using? ASP.NET? WPF? Something else? - svick
@svick, I am using ASP.NET, thx :) - Dickson Lee

1 Answers

0
votes

you have to bind dropdownlist to selecttedindex changed event of the preceding dropdownlist

also make sure that u check for page.ispostback on page load so that no bugs r there

ofcourse it can be done through sqldatasource and u can also play with defaultview of the dataset (by applying filters to already filled data)

hope this helps :) ... if there r some doubts let me know :)