Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP ASP.NET drop-down
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
 
button1_click()
{
    dropdownlist1.SelectedValue.ToString();
}
how i do return text of selected item with click on button1?
Posted 29-Jun-12 6:05am
Edited 29-Jun-12 6:29am
v2
Comments
Vitaly Tomilov at 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 at 29-Jun-12 11:36am
   
sorry!!!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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:
if(!IsPostback)
{
   // dropdown bind code
}
  Permalink  
Comments
sadegh_rusta at 29-Jun-12 12:00pm
   
ok th
Sandeep Mewara at 29-Jun-12 12:52pm
   
Welcome.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

dropdownlist1.SelectedText.ToString()
 
Bye!!!
  Permalink  
Comments
sadegh_rusta at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 398
1 DamithSL 255
2 OriginalGriff 230
3 Zoltán Zörgő 149
4 Dave Kreskowiak 120
0 OriginalGriff 7,575
1 DamithSL 5,529
2 Sergey Alexandrovich Kryukov 5,279
3 Maciej Los 4,961
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 29 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100