how to get selected value from dropdown list

A

Andy Sutorius

Hi,

I created a web user control, a dropdown list of countries which binds to a
select statement. I have placed that control in 2 different locations within
the same form, but in different panels. When the page loads the control
binds and displays perfectly. How do I get the selected value of each drop
down?

Thanks,

Andy
 
Joined
Feb 11, 2011
Messages
2
Reaction score
0
Hello. i have a dropdown list, its asp.net control
Code:
<asp:DropDownList ID="searchdroplist" runat="server" 
        onselectedindexchanged="searchdroplist_SelectedIndexChanged">
        <asp:ListItem Value = "n" Selected="False">Search By Name</asp:ListItem>
        <asp:ListItem Value = "r">Search By Roll#</asp:ListItem>
    </asp:DropDownList>

i have two lables and i want to show a lable mean lable.visible = true; on a specific list item selected.
i m writing
Code:
if (searchdroplist.SelectedItem.Value == "n") {

                namelbl.Visible = true;
}
but its not working for me. what is the mistake in this code?
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top