Gridview 复选框多选删除操作

<asp:GridView ID="Griw_List" runat="server" HeaderStyle-BackColor="YellowGreen" class="table table-bordered table-hover" AutoGenerateColumns="False" GridLines="None" Width="100%">

<Columns>

<asp:TemplateField>

<ItemTemplate>
<asp:CheckBox ID="Chex_Selete" title='<%# Eval("G_xuexiaosn") %>' name='<%# Eval("G_SN") %>' runat="server" />
<asp:Label ID="J_SN" runat="server" Text='<%# Eval("G_SN") %>' Visible="False"></asp:Label>
<asp:Label ID="J_ShenPiZhuangTai" runat="server" Text='<%# Eval("G_ShengJiShenHeZT") %>' Visible="False"></asp:Label>
</ItemTemplate>
<HeaderTemplate>
<input id="Chex_choice" type="checkbox" onclick="return Chex_choice_onclick()" />
</HeaderTemplate>
</asp:TemplateField>

</Columns>
</asp:GridView>

 

 

 

 

Int32 count = 0;
for (int g = 0; g < this.Griw_List.Rows.Count; g++)
{
CheckBox _CheckBox = (CheckBox)this.Griw_List.Rows[g].FindControl("Chex_Selete");
if (_CheckBox.Checked)
{
Label J_SN = (Label)this.Griw_List.Rows[g].FindControl("J_SN");
Label J_ShenPiZhuangTai = (Label)this.Griw_List.Rows[g].FindControl("J_ShenPiZhuangTai");

if (J_ShenPiZhuangTai.Text != "2")
{
MyJiZheZheng_BaoMingDian.SetDelete(Convert.ToInt32(J_SN.Text), 2, "删除人:" + MyUser.Info.R_Name + "(SN:" + MyUser.Info.R_SN + ")、时间:" + DateTime.Now + "、IP:" + Request.ServerVariables["REMOTE_ADDR"].ToString() + "(" + IPLocation.IPLocation.IPLocate(Server.MapPath("~/App_Data/IPLibrary.Dat"), Request.ServerVariables["REMOTE_ADDR"].ToString()) + ")");

MyNongCun_GangWei.Delete(Convert.ToInt32(J_SN.Text));
count++;
}
}
}

posted @ 2017-12-12 11:13  张三道  阅读(1180)  评论(0编辑  收藏  举报