在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
GridView自带的分页功能实现: 要实现GrdView分页的功能 现在开始实现分页的功能: 1、在<<asp:GridView ID=......>后添加,OnPageIndexChanging="GridView1_PageIndexChanging" GridView添加CheckBox列实现全选/全部取消功能 首先GridView编辑模版,在模板上添加CheckBox控件,之后将新添加列字段转换为TemplateFiled 复制代码 代码如下: using System; using System.Data; using System.Configuration; 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; using System.Data.SqlClient; public partial class Default5 : System.Web.UI.Page string sqlstr = "delete from 飞狐工作室 where 身份证号码='" + GridView1.DataKeys[i].Value + "'"; 前台主要代码: 复制代码 代码如下: <asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False" CellPadding="3" Font-Size="9pt" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"> <FooterStyle BackColor="White" ForeColor="#000066" /> <Columns> <asp:TemplateField> <ItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" /> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="身份证号码" HeaderText="用户ID" SortExpression="身份证号码" /> <asp:BoundField DataField="姓名" HeaderText="用户姓名" SortExpression="姓名"/> <asp:BoundField DataField="家庭住址" HeaderText="家庭住址" SortExpression="家庭住址"/> </Columns> <RowStyle ForeColor="#000066" /> <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" /> <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" /> </asp:GridView> <asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack="True" Font-Size="9pt" OnCheckedChanged="CheckBox2_CheckedChanged" Text="全选" /> <asp:Button ID="Button1" runat="server" Font-Size="9pt" Text="取消" onClick="Button1_Click" /> <asp:Button ID="Button2" runat="server" Font-Size="9pt" Text="删除" onClick="Button2_Click" /> |
请发表评论