Master/Detail DropDownList and DataGrid

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved

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
  #11
Dec 10th, 2008
i have two drop downlist wen i select india the partcular states shld come....but my selected index function is different from urs....is it correct
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 268
Reputation: Traicey is an unknown quantity at this point 
Solved Threads: 19
Traicey's Avatar
Traicey Traicey is offline Offline
Posting Whiz in Training

Re: Master/Detail DropDownList and DataGrid

 
0
  #12
Dec 10th, 2008
Is your DDL filled with each country?
Some people get so rich they lose all respect for humanity. That's how rich I want to be.
Reply With Quote Quick reply to this message  
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
  #13
Dec 10th, 2008
hi myrequirement is i have two dropdownlist one is country n other is statename.....wen i selelc india corresponding states shls come...but i see my selected index function is different from urs...pls explain tat...n is my code right..iam not getting the output....

one more thing how did u create the table for tat category..like i inserted 79 countries.....with id...now in state table i need to insert 28 states for india..
stateid statename countryid.....or i need to have stateid statename1........statename28 countryid
Reply With Quote Quick reply to this message  
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
  #14
Dec 10th, 2008
ya i got all the countries wic i inserted into ddllcountryname
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 268
Reputation: Traicey is an unknown quantity at this point 
Solved Threads: 19
Traicey's Avatar
Traicey Traicey is offline Offline
Posting Whiz in Training

Re: Master/Detail DropDownList and DataGrid

 
0
  #15
Dec 10th, 2008
I had the same problem my DDL doesnt talk to me back if I just select and do nothing, I couldnt figure out what was the problem because I had selectedChanged event but then until I had a button which I named to go and I didnt code anything on the button I just drag and dropped it so I select something from the DDL and click in the button and it worked just try that to see if its working then u will fix that problem later
Some people get so rich they lose all respect for humanity. That's how rich I want to be.
Reply With Quote Quick reply to this message  
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
  #16
Dec 10th, 2008
its registration form ..i cant keep button na...u find this in many site select country n corresponidng states will come in another dropdownlist...but the code iam not finding
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 268
Reputation: Traicey is an unknown quantity at this point 
Solved Threads: 19
Traicey's Avatar
Traicey Traicey is offline Offline
Posting Whiz in Training

Re: Master/Detail DropDownList and DataGrid

 
0
  #17
Dec 10th, 2008
U jst need to make sure that the countryID on the state table is corresponding to the one on the country name, then you can have a select stateme like this on ur dataadpater

  1. SELECT * FROM State
  2. WHERE CountryID = ddlCountries.selectedValue;

Im sory I cant read your code can u edit it and make it C# instead of just text, its killing me

[ Code=C# ]
Paste code here dont leave
[ /Code ]
there souldnt be any space in between ur square brackets
Some people get so rich they lose all respect for humanity. That's how rich I want to be.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 268
Reputation: Traicey is an unknown quantity at this point 
Solved Threads: 19
Traicey's Avatar
Traicey Traicey is offline Offline
Posting Whiz in Training

Re: Master/Detail DropDownList and DataGrid

 
0
  #18
Dec 10th, 2008
I think at the moment u can use that to debug and see whats working and what's not working then after that u can fix ur selectedindexchanged event on DDL
Some people get so rich they lose all respect for humanity. That's how rich I want to be.
Reply With Quote Quick reply to this message  
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
  #19
Dec 10th, 2008
  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3. Response.Write("sql is connected");
  4. SqlDataAdapter da = new SqlDataAdapter("select countryid,countryname from countryname", cn);
  5. DataSet ds = new DataSet();
  6. da.Fill(ds,"countryname");
  7. ddlcountryname.DataSource = ds.Tables["countryname"];
  8. ddlcountryname.DataTextField = "countryname";
  9. ddlcountryname.DataValueField = "countryid";
  10. ddlcountryname.DataBind();
  11.  
  12.  
  13. }
  14. protected void ddlcountryname_SelectedIndexChanged(object sender, EventArgs e)
  15. {
  16. string country_id;
  17. country_id = ddlcountryname.SelectedValue.ToString();
  18. SqlDataAdapter da1=new SqlDataAdapter("select stateid,statename from statename where countryid=' country_id'",cn);
  19. DataSet ds1 = new DataSet();
  20. da1.Fill(ds1, "statename");
  21. ddlstatename.DataSource = ds1.Tables["statename"];
  22. ddlstatename.DataTextField = "statename";
  23. ddlstatename.DataValueField = "stateid";
  24. ddlstatename.DataBind();
  25. }
Last edited by peter_budo; Dec 10th, 2008 at 6:50 am. Reason: Correcting closing tag from [\code] to [/code]
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 268
Reputation: Traicey is an unknown quantity at this point 
Solved Threads: 19
Traicey's Avatar
Traicey Traicey is offline Offline
Posting Whiz in Training

Re: Master/Detail DropDownList and DataGrid

 
0
  #20
Dec 10th, 2008
SqlDataAdapter da1=new SqlDataAdapter("select stateid,statename from statename where countryid=' country_id'",cn);
Why your country_ID which you declared as a string is within single and double qoutation marks

Try this and see if it helps
SqlDataAdapter da1=new SqlDataAdapter("select stateid,statename from statename where countryid = " + country_id ,cn);
Last edited by Traicey; Dec 10th, 2008 at 5:57 am.
Some people get so rich they lose all respect for humanity. That's how rich I want to be.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the ASP.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC