View Single Post
Join Date: Dec 2008
Posts: 21
Reputation: divyasrinivasan is an unknown quantity at this point 
Solved Threads: 0
divyasrinivasan divyasrinivasan is offline Offline
Newbie Poster

Re: Master/Detail DropDownList and DataGrid

 
0
  #10
Dec 10th, 2008
pls give me the complete code for it ..i tryed but not getting the output..pls help..iam pasting the code here but no output


  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3.  
  4.  
  5. Response.Write("sql is connected");
  6. SqlDataAdapter da = new SqlDataAdapter("select countryid,countryname from countryname", cn);
  7. DataSet ds = new DataSet();
  8. da.Fill(ds,"countryname");
  9. ddlcountryname.DataSource = ds.Tables["countryname"];
  10. ddlcountryname.DataTextField = "countryname";
  11. ddlcountryname.DataValueField = "countryid";
  12. ddlcountryname.DataBind();
  13.  
  14.  
  15. }
  16. protected void ddlcountryname_SelectedIndexChanged(object sender, EventArgs e)
  17. {
  18. string country_id;
  19. country_id = ddlcountryname.SelectedValue.ToString();
  20. SqlDataAdapter da1=new SqlDataAdapter("select stateid,statename from statename where countryid=' country_id'",cn);
  21. DataSet ds1 = new DataSet();
  22. da1.Fill(ds1, "statename");
  23. ddlstatename.DataSource = ds1.Tables["statename"];
  24. ddlstatename.DataTextField = "statename";
  25. ddlstatename.DataValueField = "stateid";
  26. ddlstatename.DataBind();
  27. }
my database is something like this...i have two tables countryname(countryid identity(1,1),countryname) and statename(stateid identity(100,1),statename,countryid)

so i have inserted 78 countries in country table in tat 73rd is india...
n i have inserted states of india in statename table(28)..how to get india's states wen india in selected
Last edited by peter_budo; Dec 10th, 2008 at 6:49 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote