ASP.net DetailsView,GridView and DropDownLists, not postbacking correctly...?

David

New member
I want three DDL's, and a Gridview. Each DDL will have text of "-Select-", and DDL-2 and DDL-3 will not be enabled to begin. DDL-1 will allow users to select the Year of a vehicle. When DDL-1's selected index changes, I want DDL-2 to be enabled, I want it to still show "-Select-" and I want it's contents to only be Makes of cars made in that year. When the user selects a Make from DDL-2, I want DDL-3 to be enabled, and to show "-Select-" and its contents to be Models of Vehicles made in DDL-1's year, and DDL-2's Make. When a user selects a Model, I want the GridView to be populated with all of the Vehicles made in DDL-1's year, DDL-2's Make, and DDL-3's Model.

Here are the issues I am having. Because "-Select-"s value is not a valid "Make" or "Model", when those SqlDataSources try to use those values, I get an error. What do I do about that?

Another issue. If I leave out the "-Select-" text, my data sources operate correctly, and when I select a year, DDL-2 is in fact filled with valid Makes for that year, and selected index is automatically 0. This in turn triggers DDL-3 to have valid Models, and gives selected index 0, which in turn triggers the Gridview which shows valid vehicles. The problem is that the user wasn't forced to pick a Make and Model, they just had to pick a year. This is not what I want.

Along the same lines, the gridview updates on each postback. How should I suppress this until each DDL has had its value selected manually?

Similarly, the reason I want the "-Select-" is because if they select a year, and a Make is selected, what if that's the make they want? Then DDL-2's selected index never changes, and this never triggers my "enable" of DDL-3.

Sorry, there's more. Once every DDL has a value, and the Gridview is displaying valid vehicles, when the user changes DDL-1, the year, DDL-2's contents change on postback, I guess the data source updates, but DDL-3's, and the Gridview's contents are still based on the last configuration of DDL-1, DDL-2, and DDL-3. I don't know why this is.

Any help on any of these issues would be greatly appreciated. I know there are sites that do this successfully, but I can't figure out what I'm doing wrong. www.carpartswholesale.com is a great example of exactly what I want my DDL's to do.

Thanks a lot!
 
Back
Top