Click here to Skip to main content
15,892,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want when select a item of dropdown list, return text of selected item because when I do click on the a item of dropdown list and click on button1 give me 1 or first item of dropdownlist

C#
button1_click()
{
    dropdownlist1.SelectedValue.ToString();
}

how i do return text of selected item with click on button1?
Posted
Updated 29-Jun-12 5:29am
v2
Comments
Vitaly Tomilov 29-Jun-12 11:31am    
I have corrected the question formatting as much as I could, but from the English perspective, it is still a mess. Please update your question to make it easier to understand.
sadegh_rusta 29-Jun-12 11:36am    
sorry!!!

Looks like you forgot to put your dropdown bind code in Page.IsPostback property. If you do not do this then on every post back, dropdown will rebind and get reset to first value.

Do:
C#
if(!IsPostback)
{
   // dropdown bind code
}
 
Share this answer
 
Comments
sadegh_rusta 29-Jun-12 12:00pm    
ok th
Sandeep Mewara 29-Jun-12 12:52pm    
Welcome.
SQL
dropdownlist1.SelectedText.ToString()


Bye!!!
 
Share this answer
 
Comments
sadegh_rusta 29-Jun-12 11:35am    
sorry
i do it but return always first item !!!

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