天天看點

AspNetPager綁定DataSet

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

<webdiyer:AspNetPager ID="AspNetPager1" OnPageChanged="AspNetPager1_PageChanged" runat="server" PageSize="12" NumericButtonCount="8" ShowCustomInfoSection="right" PagingButtonSpacing="5" ShowInputBox="always" HorizontalAlign="right" SubmitButtonText="轉到" NumericButtonTextFormatString="[{0}]" FirstPageText="首頁" LastPageText="尾頁" NextPageText="下一頁" PrevPageText="上一頁">

</webdiyer:AspNetPager>

DataSet ds = blf.GetProDataSet("Get_KCDB_List", strBeginDate, strEndDate);

            DataView dv = ds.Tables[0].DefaultView;

            AspNetPager1.RecordCount = dv.Count;

            if (dv.Count > 0)

            {

                PagedDataSource pds = new PagedDataSource();

                pds.DataSource = dv;

                pds.AllowPaging = true;

                pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;

                pds.PageSize = AspNetPager1.PageSize;

                GridView1.DataSource = pds;

                GridView1.DataBind();

                //顯示記錄資訊  

                AspNetPager1.CustomInfoHTML = "共有:<font color=/"blue/"><b>" + AspNetPager1.RecordCount.ToString() + "</b></font>條記錄";

                AspNetPager1.CustomInfoHTML += " <font color=/"red/"><b>" + AspNetPager1.CurrentPageIndex.ToString() + "</b></font>";

                AspNetPager1.CustomInfoHTML += "/<font color=/"blue/"><b>" + AspNetPager1.PageCount.ToString() + "</b></font>";