后台
PagedDataSource pds = new PagedDataSource(); pds.DataSource = dt.DefaultView; pds.AllowPaging = true; pds.PageSize = 20; int curpage; if (Request.QueryString["page"] != null) { curpage = Convert.ToInt32(Request.QueryString["page"]); } else { curpage = 1; } pds.CurrentPageIndex = curpage - 1; Label1.Text = curpage.ToString(); Label2.Text = pds.PageCount.ToString(); int intAllNum = pds.PageCount; string strPager = ""; if (intAllNum > 0) { for (int i = 0; i < intAllNum; i++) { strPager += "<a style=\"color:#ff0000\" href ='?page=" + (i + 1) + "'>" + (i + 1) + "</a> "; } Label3.Text = strPager; } if (!pds.IsFirstPage) { HyperLink1.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(curpage - 1); } if (!pds.IsLastPage) { HyperLink2.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(curpage + 1); } this.Repeater_checkList.DataSource = pds; Repeater_checkList.DataBind();
前台
<table cellpadding="0" cellspacing="0" border="0" width="90%" style=" margin:0 auto;"> <tr> <td style="text-align: center; font-size: 14px; height: 40px; line-height: 40px;"> 第> <font color="red" style="font-weight: bold"> <asp:Label ID="Label1" runat="server" Text=""></asp:Label></font><页 <asp:Label ID="Label3" runat="server" Text=""></asp:Label> <asp:HyperLink ID="HyperLink1" runat="server"><span class="kuang">上一页</span></asp:HyperLink> <asp:HyperLink ID="HyperLink2" runat="server"><span class="kuang">下一页</span></asp:HyperLink> 共> <font color="red" style="font-weight: bold"> <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label></font> <页 </td> </tr> </table>