Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my application,I want a college id of selected college name. The college name is selected from drop down list. How can i get college id of corressponding selected college name.Please give me query in sql server to obtain this?
Thanks.
Posted

The best answer for this question takes more time than I have available in detail. If you need this kind of info, the stored proc you used to populate the list should already return the desired info. At that point, you merely bind the list (with the most appropriate/desired binding mechanism), and when the item is selected in the list, you can get the id from the bound object.

Sorry, I don't have time to post sample code, but since you're a programmer, the instructions above should really be enough to get you started.
 
Share this answer
 
C#
string sql = string.Format(select * from department"

DataTable tab = new DataTable();
open_con();
SqlDataAdapter adp = new SqlDataAdapter(sql, con);
adp.Fill(tab);
close_con();

Dropdepartment.DataSource = tab;
Dropdepartment.DataTextField = "Department_name";
Dropdepartment.DataValueField = "DepartmentID";
Dropdepartment.DataBind();


then in button click event u you can write
string colleageID =Dropdepartment.SelectedValue;
 
Share this answer
 
v2
Comments
#realJSOP 5-Aug-11 7:25am    
Do NOT use textspeak here.

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