View Single Post
Join Date: Nov 2007
Posts: 40
Reputation: raghu.8 is an unknown quantity at this point 
Solved Threads: 0
raghu.8 raghu.8 is offline Offline
Light Poster

Re: populate two dropdownlist

 
0
  #3
Dec 1st, 2007
thank you or ypur advice
but i am developing web application using C#,just look at my code which is giving error message...
  1. if (Page.IsPostBack == false)
  2. {
  3. SqlConnection con = new SqlConnection("user id=sa;password=vubrain;database=raghu;data source=vubrain4");
  4. SqlDataAdapter da = new SqlDataAdapter("select countyr_id,countryname from country_master", con);
  5. DataSet ds1 = new DataSet();
  6. da.Fill(ds1, "country_master");
  7. dd1.DataSource = ds1.Tables["country_master"];
  8. dd1.DataTextField = "countryname";
  9. dd1.DataValueField = "countyr_id";
  10. dd1.DataBind();
  11. }
  12. }
  13. protected void dd1_SelectedIndexChanged(object sender, EventArgs e)
  14. {
  15. string countryid;
  16. countryid = dd1.SelectedValue;
  17. SqlConnection con = new SqlConnection("user id=sa;password=vubrain;database=raghu;data source=vubrain4");
  18. SqlDataAdapter da1 = new SqlDataAdapter("SELECT stateid,statename FROM countrystate");
  19. DataSet ds1 = new DataSet();
  20. da1.Fill(ds1, "countrystate");
  21. dd2.DataSource = ds1.Tables["countrystate"];
  22. dd2.DataTextField = "statename";
  23. dd2.DataValueField = "stateid";
  24. dd2.DataBind();
  25.  
  26.  
  27. }
  28. protected void dd2_SelectedIndexChanged(object sender, EventArgs e)
  29. {
  30. string stateid;
  31. stateid = dd2.SelectedValue;
  32.  
  33. }
If i want to select any country from 1st dropdownlist then,2nd dropdownlist should populate with all the state of that paticular country only and if we select any state from 2nd dropdown then the capital should be placed in text box beside that and so on...
Last edited by cscgal; Dec 4th, 2007 at 3:07 am. Reason: Added code tags
Reply With Quote