Click here to Skip to main content
15,905,875 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
how to get selected dropdownlist value?
Posted

C#
ddlYourDropDown.SelectedItem.Value
 
Share this answer
 
Try ddl.Text or ddl.SelectedItem
 
Share this answer
 
Try below:

SQL
TextBox1.Text =  Convert.Tostring(DropdownList1.SelectedItem.Value);

TextBox1.Text =  Convert.Tostring(DropdownList1.SelectedItem.Text);


Check this link for more info : how to display selected values from dropdown list asp.net[^]
 
Share this answer
 
C#
Textbox1.Text = Convert.ToInt32(DropdownList1.selectedvalue.ToString());
 
Share this answer
 
v2
int i = Convert.ToInt32(drpsubcat.SelectedIndex);
 
Share this answer
 
I tried this ,run successfully in asp.net

C#
string a=DropDownList1.SelectedValue;
Label1.Text = a;


If you are using windows form application then i think you may go with combobox and code for that

string a = Convert.ToString(ComboBox1.SelectedValue);


If it doesnt helps reply me
 
Share this answer
 
C#
Response.Write(DropDownList1.SelectedValue);

This will print the selected Value not the Text for that Dropdownlist.
 
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