如何使用Jquery检查在gridview中检查了多少个复选框? [英] How to check how many checkboxes are checked inside a gridview using Jquery?
问题描述
我有一个带有模板字段的Gridview。模板字段包含checkbox.Suppose我点击了两个复选框并进行了检查。我想知道复选框的索引及其值(ON或OFF)。 gridview的代码如下:
I have one Gridview with a template field. Template field contains the checkbox.Suppose i clicked on two check boxes and made it checked. I want to know the index of the checkbox and its value(ON or OFF). The code for gridview is given below:
<asp:GridView ID="GridView1" runat="server"
onrowdatabound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
.CS文件的代码如下:
protected void Button1_Click(object sender,EventArgs e)
{
DataTable table = new DataTable();
table.Columns.Add(Dosage,typeof(int));
table.Columns.Add (药物,typeof(字符串));
table.Columns.Add(Patient,typeof(string));
table.Columns.Add(日期,typeof(DateTime));
//
//这里w e添加五个DataRows。
//
table.Rows.Add(25,Indocin,David,DateTime.Now);
table.Rows.Add(50,Enebrel,Sam,DateTime.Now);
table.Rows.Add(10,Hydralazine,Christoff,DateTime.Now );
table.Rows.Add(21,Combivent,Janet,DateTime.Now);
table.Rows.Add(100,Dilantin) ,Melanie,DateTime.Now);
GridView1.DataSource = table;
GridView1.DataBind();
}
And the code for the .CS file is given below:
protected void Button1_Click(object sender, EventArgs e)
{
DataTable table = new DataTable();
table.Columns.Add("Dosage", typeof(int));
table.Columns.Add("Drug", typeof(string));
table.Columns.Add("Patient", typeof(string));
table.Columns.Add("Date", typeof(DateTime));
//
// Here we add five DataRows.
//
table.Rows.Add(25, "Indocin", "David", DateTime.Now);
table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now);
table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now);
table.Rows.Add(21, "Combivent", "Janet", DateTime.Now);
table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now);
GridView1.DataSource = table;
GridView1.DataBind();
}
推荐答案
这篇关于如何使用Jquery检查在gridview中检查了多少个复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!