前台代码:
- HTML code
<asp:GridView ID="GVPublish" runat="server" CssClass="GridViewStyle" AutoGenerateColumns="False" Width="100%" EmptyDataText='<p style="text-align: center"><span style="color: #ff6600">*无数据*</span></p>' AllowPaging="True" OnPageIndexChanging="GVPublish_PageIndexChanging" PageSize="2" OnRowCommand="GVPublish_RowCommand" > <FooterStyle CssClass="GridViewFooterStyle" /> <RowStyle CssClass="GridViewRowStyle" /> <SelectedRowStyle CssClass="GridViewSelectedRowStyle" /> <AlternatingRowStyle CssClass="GridViewAlternatingRowStyle" /> <HeaderStyle CssClass="GridViewHeaderStyle" /> <Columns> <asp:BoundField DataField="Title" HeaderText="标题" /> <asp:BoundField DataField="ColumnID" HeaderText="所属栏目" /> <asp:TemplateField HeaderText="编辑"> <HeaderStyle Width="40px" /> <ItemTemplate> <asp:ImageButton ID="btnEdit" runat="server" ImageUrl="~/Images/btpaste.gif" CommandName="btnEdit" CommandArgument='<%#DataBinder.Eval(Container,"DataItem.InfoID") %>' /> </ItemTemplate> <ItemStyle HorizontalAlign="Center" Width="40px" /> </asp:TemplateField> <asp:TemplateField HeaderText="删除"> <HeaderStyle Width="40px" /> <ItemTemplate> <asp:ImageButton ID="btnDelete" runat="server" CommandName="btnDel" CommandArgument='<%#DataBinder.Eval(Container,"DataItem.InfoID") %>' ImageUrl="~/Images/btdelete.gif" OnClientClick="return confirm('是否确定删除此文章?')" /> </ItemTemplate> <ItemStyle HorizontalAlign="Center" Width="40px" /> </asp:TemplateField> </Columns> <PagerTemplate> <asp:Label ID="lblPage" runat="server" Text='<%# "第" + (((GridView)Container.NamingContainer).PageIndex + 1) + "页/共" + (((GridView)Container.NamingContainer).PageCount) + "页" %> '></asp:Label> <asp:LinkButton ID="lbnFirst" runat="Server" Text="首页" Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>' CommandName="Page" CommandArgument="First" ></asp:LinkButton> <asp:LinkButton ID="lbnPrev" runat="server" Text="上一页" Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>' CommandName="Page" CommandArgument="Prev" ></asp:LinkButton> <asp:LinkButton ID="lbnNext" runat="Server" Text="下一页" Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != (((GridView)Container.NamingContainer).PageCount - 1) %>' CommandName="Page" CommandArgument="Next" ></asp:LinkButton> <asp:LinkButton ID="lbnLast" runat="Server" Text="尾页" Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != (((GridView)Container.NamingContainer).PageCount - 1) %>' CommandName="Page" CommandArgument="Last" ></asp:LinkButton> <br /> </PagerTemplate> </asp:GridView>