日期:2014-05-19  浏览次数:20530 次

一段代码,关于手写分页程序的,请看看哪里有问题~20分表心意
前台:

<form   runat= "server ">
共有 <asp:Label   id= "lblRecordCount "   ForeColor= "red "   runat= "server "   /> 条记录          
当前为 <asp:Label   id= "lblCurrentPage "   ForeColor= "red "   runat= "server "   /> / <asp:Label   id= "lblPageCount "   ForeColor= "red "   runat= "server "   /> 页  

<asp:LinkButton   id= "lbnPrevPage "   Text= "上一页 "   CommandName= "prev "   OnCommand= "Page_OnClick "   runat= "server "   />
<asp:LinkButton   id= "lbnNextPage "   Text= "下一页 "   CommandName= "next "   OnCommand= "Page_OnClick "   runat= "server "   />

</form>


后台:

private   void   Page_Load(Object   sender,   EventArgs   e)
{
PageSize   =   10;
if(!IsPostBack)
{
CreateLabel(CreateTable());
        CurrentPage   =   0;
        ViewState[ "PageIndex "]   =   0;
        RecordCount   =   sum();
lblRecordCount.Text   =   RecordCount.ToString();
      PageCount   =   RecordCount   /   PageSize   +   1;
lblPageCount.Text   =   PageCount.ToString();
        ViewState[ "PageCount "]   =   PageCount;
}
}
}

        public   int   sum()
        {
OleDbConnection   conn=new   OleDbConnection(ConfigurationSettings.AppSettings[ "data "]+Server.MapPath(ConfigurationSettings.AppSettings[ "path "]));  
conn.Open();
                int   intCount;
                string   strCount   =   "select   count(*)   from   aa ";
                OleDbCommand   comm   =   new   OleDbCommand(strCount,   conn);
                intCount   =   Convert.ToInt32(comm.ExecuteScalar());
                return   intCount;
        }

        ICollection   CreateSource()
        {
                int   StartIndex;
                StartIndex   =   CurrentPage   *   PageSize;
                CreateLabel(CreateTable());  
        }

        public   void   Page_onClick(Object   sender,   CommandEventArgs   e)
        {
                CurrentPage   =   (int)ViewState[ "PageIndex "];
                PageCount   =   (int)ViewState[ "PageCount "];
            &nbs