首页 > 编程 > .NET > 正文

asp.net gridview多页时的批量删除

2024-07-10 12:39:53
字体:
来源:转载
供稿:网友
book_admin.aspx
代码如下:
<asp:GridView ID="grwBook" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="false" AllowPaging="true" DataKeyNames="ID" OnPageIndexChanging="grwBook_PageIndexChanging" PageSize="12">
    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <RowStyle BackColor="#EFF3FB" />
    <EditRowStyle BackColor="#2461BF" />
    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <AlternatingRowStyle BackColor="White" />
    <Columns>
    <asp:BoundField DataField="ID" HeaderText = "ID" />
    <asp:BoundField DataField="UserName" HeaderText="姓名">
    <ItemStyle Width="60px" />
    </asp:BoundField>
    <asp:BoundField DataField="Comments" HeaderText="评论">
    <ItemStyle width="500px"  />
    </asp:BoundField>
    <asp:BoundField DataField="Postdate" HeaderText="日期" />
    <asp:HyperLinkField DataNavigateUrlFields="newsid" DataNavigateUrlFormatString="../news_zi.asp?id={0}" HeaderText="文章"  DataTextField="newsid" target="_blank" />
    <asp:TemplateField HeaderText="操作" >
        <ItemTemplate>
        <asp:CheckBox runat="Server" ID="cbxId" />
        </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    <PagerSettings Mode="NextPreviousFirstLast" FirstPageText="第一页" LastPageText="末页" NextPageText="下一页" PreviousPageText="上一页" />
</asp:GridView>

book_admin.aspx.cs
代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表