<div style="text-align: center; padding-top: 10px"> <webdiyer:AspNetPager ID="AspNetPager1" runat="server" PageSize="20" FirstPageText="首页" CssClass="anpager" LastPageText="尾页" NextPageText="下一页" PageIndexBoxType="DropDownList" PrevPageText="上一页" ShowPageIndexBox="Always" SubmitButtonText="Go" TextAfterPageIndexBox="页" TextBeforePageIndexBox="转到" AlwaysShow="True" CustomInfoHTML="共%PageCount%页,当前为第%CurrentPageIndex%页" OnPageChanged="AspNetPager1_PageChanged" ShowCustomInfoSection="Right"> </webdiyer:AspNetPager> </div>
后台:
using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Web.Services; public partial class AJAX_GetMsg : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BoundUserJH(); } } private void BoundUserJH() { string strwhere = GetWhere(); AspNetPager1.RecordCount = int.Parse(rsc.ExecuteSQLThree("select count(1) from rsgl_renwu " + strwhere).ToString()); SoftDown.DataSource = Wps.Common.Util.CDataSet(rsc.ExecuteSQLTwo("select * from (SELECT ROW_NUMBER() OVER (order by rw_id)AS Row,rw_ID,rw_kahao,rw_shuliang,rw_zhiwu,rw_datatime from rsgl_renwu " + strwhere + ") TT where TT.Row between " + AspNetPager1.StartRecordIndex + " and " + AspNetPager1.EndRecordIndex, "GetMianshiliang")); SoftDown.DataBind(); } protected void AspNetPager1_PageChanged(object src, EventArgs e) { BoundUserJH(); } }
注意sql语句
select * from (SELECT ROW_NUMBER() OVER (order by rw_id)AS Row,rw_ID from rsgl_renwu " + strwhere + ") TT where TT.Row between " + AspNetPager1.StartRecordIndex + " and " + AspNetPager1.EndRecordIndex, "GetMianshiliang")