populate two dropdownlist

Please support our C# advertiser: Intel Parallel Studio Home
Reply

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
  #21
Dec 5th, 2007
hi jerry
for examle if we select usa in first dropdownlist it has to give only all the states of usa in the second dropdownlist and if we select another country from 1st dropdownlist then it has to place only those states in second dropdownlist that paticular country.
thank you
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 436
Reputation: JerryShaw is on a distinguished road 
Solved Threads: 72
JerryShaw JerryShaw is offline Offline
Posting Pro in Training

Re: populate two dropdownlist

 
0
  #22
Dec 5th, 2007
You need two database tables.
One to store the Country ID and Name
The second table to store the Country ID, State Name and State Capital. Simple one to many relationship. Each country has many states, but a state only has one capital.

Populate the first combo with the country, and the value member with the country id. The second combo will contain the state name, and you can place the capital in the value member. If you web site is doing more with the state information then you might want to place a state id in the states table, and use that as the valuemember so that you can pull additional information about the state.

In the demo, you will see the event on the second drop down selected index change uses the country id, and the state id to find the capital value to place into the Label.

--Jerry
Reply With Quote Quick reply to this message  
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
  #23
Dec 5th, 2007
hi jerry thanks for your reply
country id in the second table will be more then the country id in the first table just because one country has more number of states, can it possible to populate only paticular country's state in the second dropdownlist by the way you said?
thank you
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 436
Reputation: JerryShaw is on a distinguished road 
Solved Threads: 72
JerryShaw JerryShaw is offline Offline
Posting Pro in Training

Re: populate two dropdownlist

 
0
  #24
Dec 5th, 2007
I think you are struggling with understanding the one to many relationship.
Lets say you have 2 countrys defined in your country_master table. #1=USA, #2=Canada

You can have all USA's states listed in the states table, and you can also have all of the states found in Canada in this very same table. Each row in the states table also has a Country ID column that allows the SQL server to only get the states for a specific Country ID.

Therefore a T-SQL statement of "select * from States where Country_id=1"
will only bring back the states that belong to the USA. If Country_ID were set to 2 in this query, then only Canada's states would be returned.

The purpose of the first drop-down is to get the CountryID that will be used in the query against the States table... As long as you issue the query statement with the "where country_id = nnn", the second dropdown will only contain the states related to that country id.

Hope this Helps,
Jerry
Reply With Quote Quick reply to this message  
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
  #25
Dec 6th, 2007
thanks jerry for your reply,i will try the above said example,
and i will keep in you touch with you
raghu
Reply With Quote Quick reply to this message  
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
  #26
Dec 6th, 2007
thank you very ,very ,very much jeryy i got through your help, unless you did'nt i can't make it ,you almost saved me from every thing
thank you once again..
if possible give your phone no.so that i can make call

raghu
Reply With Quote Quick reply to this message  
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
  #27
Dec 6th, 2007
hi jerry thanks for dropdownlist, but i got another problem regarding updatating a profile of a login member, i created a storedprocedure for login information just look at my codding
  1. CREATE PROCEDURE sp_UserValidation
  2. (
  3. @Username varchar(50),
  4. @UserPassword varchar(20)
  5. )
  6. AS
  7. IF EXISTS (SELECT UserName FROM LogIn1 WHERE UserName=@Username and UserPassword=@UserPassword)
  8. BEGIN
  9. return 1
  10. END
  11. ELSE
  12. BEGIN
  13. return 0
  14. END
  15. create table login1(username varchar(50)constraint pkusername primary key,userpassword varchar(20) ,
  16. youranswer varchar(40),username varchar(20), useraddress varchar(100),usercity varchar(20),userpostal int,
  17. userphone int,usermobile int,Email varchar(30),website varchar(30))
my problem is i want to update some of login member column but iam not able to update, i wrote some coding for that just go through that,
  1. protected void Button1_Click(object sender, EventArgs e)
  2. {
  3. SqlConnection con = new SqlConnection("user id=sa;password=vubrain;database=raghu;data source=vubrain4");
  4. SqlCommand cmd = new SqlCommand();
  5. cmd.Connection = con;
  6. cmd.CommandText = "Update login1001 Set name = @username1001, pwd = @userpassword1001 where username1001= @username1001";
  7. cmd.CommandType = CommandType.Text;
  8. SqlParameter para2;
  9. SqlParameter para3;
  10. SqlParameter para4;
  11. SqlParameter para5;
  12. //SqlParameter para6;
  13. SqlParameter para7;
  14. SqlParameter para8;
  15. SqlParameter para9;
  16. para2 = cmd.@Parameters.AddWithValue("loginaddress", tb1.Text);
  17. para3 = cmd.@Parameters.AddWithValue("logincity", t6.Text);
  18. para4 = cmd.@Parameters.AddWithValue("loginpostalcode", t7.Text);
  19. para5 = cmd.@Parameters.AddWithValue("loginphone", t8.Text);
  20. //para6 = cmd.Parameters.AddWithValue("loginfax", t9.Text);
  21. para7 = cmd.@Parameters.AddWithValue("loginmobile", t10.Text);
  22. para8 = cmd.@Parameters.AddWithValue("loginemail", t11.Text);
  23. para9 = cmd.@Parameters.AddWithValue("loginwebsite", t12.Text);
  24. int intnum;
  25. con.Open();
  26. intnum = cmd.ExecuteNonQuery();
  27. if (intnum > 0)
  28. {
  29. Label2.Text = "updated successfully";
  30.  
  31. }
  32. else
  33. {
  34. Label2.Text = "updarted failed";
  35. }
  36. con.Close();
please sought out my problem
thank you
raghu
Last edited by cscgal; Dec 6th, 2007 at 5:37 am. Reason: Added code tags
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 2,414
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Solved Threads: 123
Team Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: populate two dropdownlist

 
0
  #28
Dec 6th, 2007
Hi there,

You might want to create a new thread for this question, since it's not related to your other question. That way, more people will look at your question...
Alex Cavnar, aka alc6379
Reply With Quote Quick reply to this message  
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
  #29
Dec 6th, 2007
ok thanks for informing
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 24
Reputation: waterfall is an unknown quantity at this point 
Solved Threads: 0
waterfall waterfall is offline Offline
Newbie Poster

Re: populate two dropdownlist

 
0
  #30
Dec 29th, 2007
How do we convert it into C# web forms?
can you please help me in converting dd1_SelectedIndexChanged for web form.Plz help me.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC