本文介绍了如何使用jQuery计算GridView内部下拉菜单中的选定选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在gridview中有几个下拉菜单,每个下拉菜单都有2个相同的选项,我想从所有这些下拉列表中计算出option1被选择的次数(selectedIndex = 1)以及第二个选项被选择的次数(selectedIndex = 2)使用jQuery.
I have a few dropdowns in my gridview, each has 2 same options, I want to calculate out of all these dropdowns how many times is option1 selected (selectedIndex = 1) and how many times the second option is selected (selectedIndex = 2) using jQuery.
<asp:GridView ID="gd1" runat="server" AutoGenerateColumns="False"
onrowdatabound="gd1_RowDataBound" >
<Columns>
<asp:BoundField DataField="id" Visible="False"/>
<asp:BoundField DataField="fullName" Visible="True"
HeaderText="Full Name"/>
<asp:TemplateField >
<ItemTemplate>
<asp:DropDownList ID="ddl1" runat="server" ></asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField >
<ItemTemplate>
<asp:DropDownList ID="ddl2" runat="server"></asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField >
<ItemTemplate>
<asp:DropDownList ID="ddl3" runat="server"></asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="Count1" runat="server" Text="First Count"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="CountSelected1" runat="server" ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="Count2" runat="server" Text="Second Count"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="CountSelected2" runat="server" ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
在最后两列中,我想显示option1和option2的选择总数.
In the final 2 columns I want to display the total number of selections of option1 and option2.
推荐答案
var collection =
这篇关于如何使用jQuery计算GridView内部下拉菜单中的选定选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!