I have a ASP.NET GridView control and DropDownList control inside the GridiView as below:
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
I wanted to use jQuery/ JavaScript to get DropDownList element and detect the item change as below:
$(function() {
$("#<%= DropDownList1.ClientID %>").change(function() {
if ($("#<%= DropDownList1.ClientID %>").find('option:selected').text() == "1") {
alert('1');
} else {
alert('2');
}
});
});
My question is, how can I select the DropDownList inside GridView, and then check for the changes?
Please advise. Thank you in advanced.