做批量删除好像不这么麻烦了,我做过全选删除了,里面包含可以全选的,单选的.
我想应该是你的要的结果吧!!!
<asp:TemplateField HeaderText="全选">
<HeaderTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" Text="全选" onclick="ok(this)" />
</HeaderTemplate>
function ok(CheckBox)
{
var GridView = document.getElementById("GridView1");
for(var i=1;i<GridView.rows.length-1;i++)
{
GridView.rows[i].cells[0].getElementsByTagName("input")[0].checked=CheckBox.checked;
}
}
这是全选了,下面是删除的事件了.
protected void btnDelete_Click(object sender, EventArgs e)
{
SKK.BBL.FactoryReceiptCloth factory = new SKK.BBL.FactoryReceiptCloth();
foreach (GridViewRow i in GridView1.Rows)
{
if ((i.FindControl("CheckBox1") as CheckBox).Checked == true)
{
int Fa_id = int.Parse(GridView1.DataKeys[i.RowIndex].Value.ToString());
if (factory.FactoryReceiptClothDelete(Fa_id))
{
("删除成功!");
}
else
{
("删除失败!");
}
}
}
Bind();
}
我想应该是你的要的结果吧!!!
<asp:TemplateField HeaderText="全选">
<HeaderTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" Text="全选" onclick="ok(this)" />
</HeaderTemplate>
function ok(CheckBox)
{
var GridView = document.getElementById("GridView1");
for(var i=1;i<GridView.rows.length-1;i++)
{
GridView.rows[i].cells[0].getElementsByTagName("input")[0].checked=CheckBox.checked;
}
}
这是全选了,下面是删除的事件了.
protected void btnDelete_Click(object sender, EventArgs e)
{
SKK.BBL.FactoryReceiptCloth factory = new SKK.BBL.FactoryReceiptCloth();
foreach (GridViewRow i in GridView1.Rows)
{
if ((i.FindControl("CheckBox1") as CheckBox).Checked == true)
{
int Fa_id = int.Parse(GridView1.DataKeys[i.RowIndex].Value.ToString());
if (factory.FactoryReceiptClothDelete(Fa_id))
{
("删除成功!");
}
else
{
("删除失败!");
}
}
}
Bind();
}
小弟,身高1.60米,农村户口,小学文化,家有农田1亩.