如何使用 aspnetpager

<%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix="webdiyer" %>

  <webdiyer:AspNetPager id="AspNetPager1" runat="server" ShowPageIndexBox="Always" 
                                            PageSize="20" OnPageChanged="AspNetPager1_PageChanged" 
                                            TextBeforeInputBox="转到第  " 
              TextAfterInputBox="  页  " ShowPageIndex="False" 
                                            ShowInputBox="Always" 
              ShowCustomInfoSection="Left" PrevPageText="上一页" 
                                            NextPageText="下一页" LastPageText="尾页" 
              FirstPageText="首页" AlwaysShow="True" 
                                            CustomInfoSectionWidth="600" 
              CustomInfoTextAlign="NotSet" LayoutType="Table">
      </webdiyer:AspNetPager>


    
        <webdiyer:AspNetPager ID="AspNetPager2" runat="server" CloneFrom="AspNetPager1">
        </webdiyer:AspNetPager>

  

 public void checkCase()
        {
            string strSql = " ID>0";
            int num = bll.GetRecordCount(strSql);
            AspNetPager1.RecordCount = num;
            DataSet ds = bll.GetAspNetPagerDataSet(strSql, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize);
            if (ds.Tables[0].Rows.Count > 0)
            {
                this.Repeater1.DataSource = ds.Tables[0].DefaultView;
                this.Repeater1.DataBind();

                AspNetPager1.CustomInfoHTML = "共:<font color=\"red\"><b>" + AspNetPager1.RecordCount.ToString() + "</b></font>&nbsp;&nbsp;条记录";
                AspNetPager1.CustomInfoHTML += " 总页数:<font color=\"red\"><b>" + AspNetPager1.PageCount.ToString() + "</b></font>&nbsp;&nbsp;页";
                AspNetPager1.CustomInfoHTML += " 每页显示:<font color=\"red\"><b>" + AspNetPager1.PageSize.ToString() + "</b></font>&nbsp;条";
                AspNetPager1.CustomInfoHTML += " 当前页:<font color=\"red\"><b>" + AspNetPager1.CurrentPageIndex.ToString() + "</b></font>&nbsp;&nbsp;";
            }
        }

 bll 

/// <summary>
        /// 获得aspnetpager分页数据
        /// </summary>
        public DataSet GetAspNetPagerDataSet(string whereSql, int mypageindex, int mypagesize)
        {
            return dal.GetAspNetPagerList(whereSql, mypageindex, mypagesize);
        }

DAL

 /// <summary>
        /// 获得AspNetPager分页数据列表
        /// </summary>
        public DataSet GetAspNetPagerList(string strWhere, int mypageindex, int mypagesize)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(" SELECT ID,sTitle,sContent,sAuthor,sAuthorTel,sAuthorQQ,sAuthorEmail,toDepart,ifPass,PubDate ");
            strSql.Append(" FROM QuestionBook ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by ID desc");
            return SQLHelper.ExecuteWebDiyerDataset(SQLHelper.DBCONNECTIONSTRING, CommandType.Text, strSql.ToString(), mypageindex, mypagesize);
        }

DBTtility

 #region 为webdiyer分页控件做的 DataSet 传递参数进来 DataSet ExecuteWebDiyerDataset(string connString, CommandType cmdType, string cmdText,int mypageindex,int mypagesize, params SqlParameter[] cmdParms)
        public static DataSet ExecuteWebDiyerDataset(string connString, CommandType cmdType, string cmdText, int mypageindex, int mypagesize, params SqlParameter[] cmdParms)
        {
            SqlDataAdapter myAdapter = new SqlDataAdapter();
            myAdapter.SelectCommand = new SqlCommand();

            using (SqlConnection conn = new SqlConnection(connString))
            {
                PrepareCommand(myAdapter.SelectCommand, conn, null, cmdType, cmdText, cmdParms);
                DataSet ds = new DataSet();
                myAdapter.Fill(ds, mypagesize * (mypageindex - 1), mypagesize, "dtable");
                myAdapter.SelectCommand.Parameters.Clear();
                return ds;

            }

        }
        #endregion

如何使用 aspnetpager,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。