Click here to Skip to main content
15,610,250 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

-I have 2 drop down lists in one contain and the other one contains the name. that are stored in SQL Server.

-I just want to that when I select the from the 1st drop down list it automatically selects the name in the in the 2nd drop down list.. which is already stored in SQL Server

-SQL Table fields contains


So, what have you tried?
xibit89 20-Aug-13 7:19am    
I don't understand the logic. I haven't tried anything yet.
ZurdoDev 20-Aug-13 7:20am    
1. Reply to the comment so that the user is notified.
2. Since you haven't done anything you should search for an example online and try to implement it. Giving you all of the code is not likely going to happen.
Jignesh Khant 20-Aug-13 7:22am    
Bind first drop down's text and value both with your srno field from db and keep autopostback onn. For second dropdown bind value with srno and text with name. Then on selected index change of first dropdown change the value of second dropdown.
xibit89 20-Aug-13 7:23am    
private void BindComb(string ddlName)
if (ddlsno == "ddlsno")
DataTable dt = new DataTable();
dt = dl.getsno();
ddlsno.DataSource = dt;
ddlsno.DataTextField = "sno";
ddlsno.DataValueField = "Name";
else if (ddlName == "ddlName")
DataTable dt = new DataTable();
dt = dl.getName();
ddlName.DataSource = dt;
ddlName.DataTextField = "Name";
ddlName.DataValueField = "sno";

this I have done for data bound

1 solution


  1. Use OnSelectedIndexChanged Method[^] of DropDownList.
  2. Get the Selected Value.
  3. Loop through the DataTable and find the Row where it has that Selected Value (S.No).
  4. Get required column value (the DropDown value, which need to be selected) in that Row.
  5. Select other DropDown by the value we got in previous step.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900