如何在GridView中选择和检查下拉列表的更改
How to select and check changes of DropDownList in GridView?
我有一个ASP。. NET GridView控件和GridView中的下拉列表控件,如下所示:
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
我想使用jQuery/JavaScript来获取DropDownList元素并检测项目的变化,如下所示:
$(function() {
$("#<%= DropDownList1.ClientID %>").change(function() {
if ($("#<%= DropDownList1.ClientID %>").find('option:selected').text() == "1") {
alert('1');
} else {
alert('2');
}
});
});
我的问题是,我如何在GridView中选择下拉列表,然后检查更改?
请建议。
使用class选择器为class
和bind
的下拉列表和事件指定class