Wrox Programmer Forums
|
Visual Web Developer 2005 Discuss creating ASP.NET 2.0 sites with Microsoft's Visual Web Developer 2005. If your question is more specific to a piece of code than the Visual tool, see the ASP.NEt 2.0 forums instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Web Developer 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 14th, 2006, 03:30 PM
Authorized User
 
Join Date: Aug 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default populating dropdown help

Hello,
Does anyone know how to Dynamically populate a 2nd dropdown based on the values of the 1st dropdown, then display the results in the Gridview? I have done the easy part of populating the 1st dropdown with the database and i can display those records, now i need to filter my records with the 2nd dropdown.
thank you


 
Old September 15th, 2006, 07:03 AM
Authorized User
 
Join Date: Sep 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Enable auto postback for the first drop down, and then in the page_load you can check if the page is post_backed (if page.ispostback() then...) then you should use the first drop down's selectedvalue as the parameter in the second drop down list. You can select this parameters, when designing the query for the SQLDataSource control itself in the "where..." button option.

Otherwise as mentioned above i was talking about page_load, you can use the Second drop down list data control's selectcommand to be specified ussing the first drop downlist's value
Something like this
SecondDataSource.SelectCommand = "Select * from SecondTable where fieldname = " & firstdropdownlist.selectedvalue

What this will do is change the datasource for the second drop down list as SecondDataSource is associated with the second drop down list. Then similarly you can work on a logic for the gridview in the same fashion as the earlier one.


Vincent Thomas
Bangalore





Similar Threads
Thread Thread Starter Forum Replies Last Post
Populating dropdown within a datagrid ninel ASP.NET 2.0 Professional 2 May 31st, 2006 02:41 AM
Populating dropdown within a datagrid ninel ASP.NET 2.0 Basics 7 May 26th, 2006 03:26 PM
Populating dropdown within a datagrid ninel General .NET 0 May 26th, 2006 12:27 PM
populating a dropdown list within a datagrid in C# akshay144 General .NET 0 May 12th, 2006 04:44 AM
populating dropdown values rupen Classic ASP Basics 16 October 10th, 2005 09:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.