Click here to Skip to main content
15,867,330 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Suppose I have a dropdownlist with several data. If My result comes as 0, then it print "UK". If 1 then it print "US". Now i want a query which result as text (country name) on the basis of selected value.
C#
<asp:ListItem Value="0">US</asp:ListItem>
<asp:ListItem Value="1">UK</asp:ListItem>
<asp:ListItem Value="2">UAE</asp:ListItem>

How can i make it possible I try so many query but doesn't reach to the solution. If any body have an idea kindly share to me.
Posted
Updated 16-Dec-12 21:58pm
v2
Comments
Rahul Rajat Singh 17-Dec-12 3:59am    
Why don't you set the value itself as UK or US.

you can add a ListItem as "selected value" as selected value
 
Share this answer
 
Comments
Mas11 17-Dec-12 4:05am    
Exactly !!
fjdiewornncalwe 4-Feb-13 10:07am    
Then why not give the credit to the person who helped you answer the question instead of posting your own.
"dropDownListId.SelectedItem.Text" gives you US, UK or UAE
 
Share this answer
 
C#
Hey I have resolved it, Its a minor task. 

<pre lang="c#">
        string s = DropDownList1.SelectedValue;
   
        ListItem li = new ListItem();
        li = DropDownList1.Items.FindByValue(s);
        Label1.Text = li.Text;
 
Share this answer
 
v2

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