Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
XML
For some reason i just cant get it to work:


            <asp:DropDownList ID="DDSortBy" runat="server"  CssClass="RightDD" OnSelectedIndexChanged="DDSortBy_SelectedIndexChanged">
                <asp:ListItem Value="0">Random</asp:ListItem>
                <asp:ListItem Value="1">Album</asp:ListItem>
                <asp:ListItem Value="2">Artist</asp:ListItem>
                <asp:ListItem Value="3">Price</asp:ListItem>
                <asp:ListItem Value="4">Top Rated</asp:ListItem>
                <asp:ListItem Value="5">Year</asp:ListItem>
            </asp:DropDownList>

i want to send the values "Random", "Album", etc to this label:

<asp:Label ID="lblSort" runat="server" Text=""></asp:Label>

Any Ideas?

Posted
Comments
ZurdoDev 29-Jul-14 14:54pm    
lblSort.Text=DDSoryBy.SelectedItem.Text won't work for you?
Zieyaad 29-Jul-14 15:03pm    
i tried that, im probably sure that it does work BUT while im running my website, i want the value/text to be immediately passed as i select an option from the drop down list.

Hi,

Use Jquery to get the selected value from dropdown and assign that to label text..


var selectedvaluefromddl = $("#DDSortBy option:selected").text();
$('#lblSort').text(selectedvaluefromddl );
 
Share this answer
 
v2
If that is really your code you need to the set the autopostback property on the control

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listcontrol.autopostback(v=vs.110).aspx[^]
 
Share this answer
 
Comments
Zieyaad 29-Jul-14 15:56pm    
GREAT STUFF

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