Reputation: 85
I have ASP.Net DropDownList bind using c#. I want to change selected value of DropDownList on Button Click Event using JQuery.
<asp:DropDownList ID="ddlSubject" runat="server" >
</asp:DropDownList>
I have tried this but did not work:
$( '#< %=ddlSubject.ClientID %> option:selected' ).val( "5" );
Upvotes: 1
Views: 3159
Reputation: 1449
If you haven't enclosed your dropdown in any grid or other container, use this:
$("#ddlSubject").val("5");
If not, use this:
$("#<%=ddlSubject.ClientID%>").val("5");
Upvotes: 2
Reputation: 982
You can set value using this
$("#<%=ddlSubject.ClientID%>").val("5");
Upvotes: 0