Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > New to .NET, can I have one drop down box control the data of another drop down box using a database?

Reply
Thread Tools

New to .NET, can I have one drop down box control the data of another drop down box using a database?

 
 
SirPoonga
Guest
Posts: n/a
 
      01-07-2005
Lets say I have a couple of tables in a database containg car make,
type, and model. I want to create a drop down box that is populated by
the makes. Based on that selection run a query to get the types of
vehicles that make creates. Then baed off that the models that fit
that make and type.
Point me in the direction of how to do this.

Thanks.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGF1bA==?=
Guest
Posts: n/a
 
      01-07-2005
One way to do this is set up a data adapter, data set and connection string
to your database on a web form, then bind the dropdown list to the dataset in
the page load. You can use a stored procedure or a select query command to
get the data from the database. The data adapter wizard is pretty good as it
will prompt for ifnormation like this. If you do a search on data adapter
you will most likely find many examples.

"SirPoonga" wrote:

> Lets say I have a couple of tables in a database containg car make,
> type, and model. I want to create a drop down box that is populated by
> the makes. Based on that selection run a query to get the types of
> vehicles that make creates. Then baed off that the models that fit
> that make and type.
> Point me in the direction of how to do this.
>
> Thanks.
>
>

 
Reply With Quote
 
 
 
 
Ben Strackany
Guest
Posts: n/a
 
      01-07-2005
Yep, pretty straight forward (hmm, should there be a hyphen in there?).

Check out the ASP.NET QuickStart to learn how to populate a dropdownlist
from the database, e.g.
http://samples.gotdotnet.com/QuickSt...ormsintro.aspx
http://samples.gotdotnet.com/QuickSt...tabinding.aspx

Try out some samples and tutorials on your own. Once you're familiar with
ASP.NET, create a web form with 3 ASP.NET DropDownList web form controls on
it: make, type, model. In your Page_Load event, have some code like this:

if (!Page.IsPostBack)
{
// this code runs when the page first loads
// populate the make dropdownlist from the database
}

Double click the make dropdownlist in the web designer -- a
make_SelectedIndexChanged method will be generated and assigned to that
dropdownlist control. Add some code to the make_OnSelectedIndexChanged event
to populate the type dropdownlist and clear the model dropdownlist . So when
a user chooses something from the make listbox, the type dropdownlist will
get automatically populated.

Double click the type dropdownlist & add some code to it's
SelectedIndexChanged event to populate the model dropdownlist . So when a
user chooses something from the type listbox, the model dropdownlist gets
populated.

It's pretty easy once you get started. If you ever worked with VB6 forms
you'll find it's pretty similar -- click forms, add code for events, etc.

Good luck!

--
Ben Strackany
www.developmentnow.com


"SirPoonga" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Lets say I have a couple of tables in a database containg car make,
> type, and model. I want to create a drop down box that is populated by
> the makes. Based on that selection run a query to get the types of
> vehicles that make creates. Then baed off that the models that fit
> that make and type.
> Point me in the direction of how to do this.
>
> Thanks.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Affecting a dynamically created drop down from another dynamically created drop down. msimmons ASP .Net 0 07-16-2009 03:17 PM
retrive preselected value in second drop down list from the first drop down list weiwei ASP .Net 0 01-05-2007 07:29 PM
Using ASP to process drop-down box data into SQL statement =?Utf-8?B?S2l3aU5FVCB1ay5nZW9jaXRpZXMuY29tL2hhcm9vbm5ldDIwMDIv?= ASP .Net 1 11-13-2005 05:29 PM
Get value of drop down list from one user control to another -- raise event? Eagle ASP .Net Datagrid Control 1 06-06-2005 10:36 PM
Samsung SCD6040 - Anyone have one, used one, or have reviews on one? g wills Digital Photography 0 09-08-2004 08:06 PM



Advertisments