Dipali Wagh
Dipali Wagh

Reputation: 85

Set selected value in asp.net DropDownList using Jquery

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

Answers (2)

Praveen
Praveen

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

jignesh patel
jignesh patel

Reputation: 982

You can set value using this

$("#<%=ddlSubject.ClientID%>").val("5");

Upvotes: 0

Related Questions