GridView删除行
- <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDeleting="GridView1_RowDeleting">
- <Columns>
- <asp:BoundField DataField="id" HeaderText="id" />
- <asp:BoundField DataField="name" HeaderText="name" />
- <asp:TemplateField ShowHeader="False">
- <ItemTemplate>
- <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete"
- Text="删除" OnClientClick='<%# "if (!confirm(\"你确定要删除" + Eval("name").ToString() + "吗?\")) return false;"%>'></asp:LinkButton>
- </ItemTemplate>
- </asp:TemplateField>
- </Columns>
- </asp:GridView>
批量删除
前台
<asp:TemplateField ItemStyle-Width="8%"> <HeaderStyle Wrap="False"></HeaderStyle> <ItemStyle></ItemStyle> <HeaderTemplate> <asp:CheckBox id="Hk_SelectAll" onclick="javascript:CheckAllGridCheckBox(this,'Hk_Select');" runat="server" Text="全选"></asp:CheckBox> </HeaderTemplate> <ItemTemplate> <span name="sel" selname="sel"> <asp:CheckBox id="Hk_Select" onclick="javascript:CheckOneGridItem('Hk_SelectAll','gv_recommendHouse','Hk_Select');" runat="server" Visible="true"></asp:CheckBox></span> </ItemTemplate> </asp:TemplateField>
protected void btn_Agent_delete_Click(object sender, EventArgs e) { string ids = "", members = ""; for (int i = 0; i < gv_recommendAgent.Rows.Count; i++) { if (((CheckBox)gv_recommendAgent.Rows[i].Cells[0].FindControl("Ak_Select")).Checked == true) { ids += gv_recommendAgent.DataKeys[i].Value + ","; members += gv_recommendAgent.DataKeys[i].Value + ","; } } Loan.Function.boc.RecommendData.DelRecommend(GetInterger(user.BankId.ToString(), 1), listType.ToString(), ids); Response.Redirect("/Manager/boc/recommendlist.aspx?list=2"); }