Jump to content

DDownbox1 Selected value to populate


LJnel

Recommended Posts

hey therei have 2 dropdownboxes on my webpage, when i choose a value in the first dropdownbox i want to then populate the 2nd dropdownbox with other values, for example:when i choose "grade 1 students" in the first dropdownbox, i want there grade 1 subjects to display in the second dropdownbox and so on ........any ideas or code examples pleasethank you :)

Link to comment
Share on other sites

double click on the first ddl in design view and the event will be setup for you (VS.Net). Let me know if you do not have VS.Net or VWD Express). VWD Express is free BTW.

private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e){    //use sql to get ddl2 contents    string sql = "SOME QUERY TO FILL DDL2";    SqlConnection cnt = new SQLConnection("connection string");    SqlCommand cmd = new SqlCommand(sql,cnt);    SqlDataReader data;    cnt.Open();    data = cmd.ExecuteReader();    ddl2.DataSource = data;    ddl2.DataBind();    data.Close();    cnt.Close();}

That may have some syntax errors but you should be able to clean it up. This is assuming you are using SQL Server....change to ODBC or OleDb depending on your needs.NOTE: DropDownList1 must have AutoPostBack set to TRUE

Link to comment
Share on other sites

it worked i got it right this afternoon, one at the end of this year i will show you the web application i am currently working on at the end of this year, i will put it on the internet.. but there is another thing i want to ask youi have a registration form where a user can register, but i have broken the form down into 3 parts and i am using ms access, everytime a user completes a part i want to just insert that part's values in my database, i want to ask if you can help me with the oledb connection just to do that a simple connection, i am working in vb.net visual studio, perhaps if you know about good sites with detailed examples of asp.net maybe it will help, most sites dont explain allthank you very much for your patienceLouis

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...