以下是一个web自定义的示例,几年前写的,写得也不是很好,权当抛砖引玉。
主要实现datagrid的分页功能:
调用使用方法:
     this.DataGrid1.ConnectionString = DataClass.ConnectionString; //这里指定一个连接字串。
    
     this.DataGrid1.strSQL = strSQL;
    
     this.DataGrid1.DataBind();
  
如果当前的sql中有identitykey,则必须指定
this.DataGrid1.IdentityKey = "字段";
然后绑定。
如果是acesss数据库
this.DataGrid1.bIsAccess = true;
还有几个其他的可选参数,看看代码就明白了。
 using
      
      
        System;
      
        using
      
      
        System;
         using
      
      
        System.Web.UI;
      
      
        using
      
      
        System.Web.UI;
         using
      
      
        System.Web.UI.WebControls;
      
      
        using
      
      
        System.Web.UI.WebControls;
         using
      
      
        System.ComponentModel;
      
      
        using
      
      
        System.ComponentModel;
         using
      
      
        System.Data;
      
      
        using
      
      
        System.Data;
         using
      
      
        System.Data.SqlClient;
      
      
        using
      
      
        System.Data.SqlClient;
         using
      
      
        System.Drawing;
      
      
        using
      
      
        System.Drawing;
         using
      
      
        System.Data.OleDb;
      
      
        using
      
      
        System.Data.OleDb;
         
         namespace
      
      
        ZFControls
      
      
        namespace
      
      
        ZFControls
         {
        
      
      
      
        
          {
           ///
          
          
          
          
            <summary>
          
        
        
        
          
            ///
          
          
          
          
            <summary>
          
          
             ///
          
          
            DataGrid
          
          
            ///
          
          
            DataGrid
             ///
          
          
            实现功能
          
          
            ///
          
          
            实现功能
             ///
          
          
          
          
            </summary>
          
          
            ///
          
          
          
          
            </summary>
          
          
          
        
         [
        
          [
           ToolboxData(
        
        
          "
        
        
          <{0}:DataGridrunat=server></{0}:DataGrid>
        
        
          "
        
        
          ),
          ToolboxData(
        
        
          "
        
        
          <{0}:DataGridrunat=server></{0}:DataGrid>
        
        
          "
        
        
          ),
           ToolboxBitmap(
        
        
          typeof
        
        
          (ZFControls.DataGrid),
        
        
          "
        
        
          Grid.bmp
        
        
          "
        
        
          )
          ToolboxBitmap(
        
        
          typeof
        
        
          (ZFControls.DataGrid),
        
        
          "
        
        
          Grid.bmp
        
        
          "
        
        
          )
           
           ]
          ]
           public
        
        
        
        
          class
        
        
          DataGrid:System.Web.UI.WebControls.DataGrid,IPostBackEventHandler
        
        
          public
        
        
        
        
          class
        
        
          DataGrid:System.Web.UI.WebControls.DataGrid,IPostBackEventHandler
           {
          
        
        
        
          
            {
             
             
             public
          
          
            DataGrid()
          
          
            public
          
          
            DataGrid()
             {
            
          
          
          
            
              {
               if
            
            
              (
            
            
              this
            
            
              .Context
            
            
              ==
            
            
            
            
              null
            
            
              )
            
            
              if
            
            
              (
            
            
              this
            
            
              .Context
            
            
              ==
            
            
            
            
              null
            
            
              )
               {
              
            
            
            
              
                {
                 this
              
              
                .ShowFooter
              
              
                =
              
              
              
              
                true
              
              
                ;
              
              
                //
              
              
                显示设计视图
              
              
                this
              
              
                .ShowFooter
              
              
                =
              
              
              
              
                true
              
              
                ;
              
              
                //
              
              
                显示设计视图
              
              
                 }
              
              
                }
              
            
            
               }
              }
            
          
          
             
             
             
             private
          
          
          
          
            int
          
          
            CurrentPageNo
          
          
            private
          
          
          
          
            int
          
          
            CurrentPageNo
             {
            
          
          
          
            
              {
               get
            
            
              get
            
            
               {
              
            
            
            
              
                {
                 
                 if
              
              
                (ViewState[
              
              
                "
              
              
                PageNo
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
              
              
                if
              
              
                (ViewState[
              
              
                "
              
              
                PageNo
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
                 {
                
              
              
              
                
                  {
                   ViewState[
                
                
                  "
                
                
                  PageNo
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  1
                
                
                  ;
                  ViewState[
                
                
                  "
                
                
                  PageNo
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  1
                
                
                  ;
                   }
                  }
                
              
              
                 return
              
              
                (
              
              
                int
              
              
                )ViewState[
              
              
                "
              
              
                PageNo
              
              
                "
              
              
                ];
              
              
                return
              
              
                (
              
              
                int
              
              
                )ViewState[
              
              
                "
              
              
                PageNo
              
              
                "
              
              
                ];
                 }
                }
              
            
            
               set
            
            
              set
            
            
               {
              
            
            
            
              
                {
                 ViewState[
              
              
                "
              
              
                PageNo
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                ViewState[
              
              
                "
              
              
                PageNo
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                 }
                }
              
            
            
               }
              }
            
          
          
             
             ///
            
            
            
            
              <summary>
            
          
          
          
            
              ///
            
            
            
            
              <summary>
            
            
               ///
            
            
              是否在列表中显示记录数,默认为True
            
            
              ///
            
            
              是否在列表中显示记录数,默认为True
               ///
            
            
            
            
              </summary>
            
            
              ///
            
            
            
            
              </summary>
            
            
            
          
           private
          
          
          
          
            bool
          
          
            ShowRecordCount
          
          
          
            private
          
          
          
          
            bool
          
          
            ShowRecordCount
             {
            
          
          
          
            
              {
               get
            
            
              get
            
            
               {
              
            
            
            
              
                {
                 
                 if
              
              
                (ViewState[
              
              
                "
              
              
                ShowRecordCount
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
              
              
                if
              
              
                (ViewState[
              
              
                "
              
              
                ShowRecordCount
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
                 {
                
              
              
              
                
                  {
                   ViewState[
                
                
                  "
                
                
                  ShowRecordCount
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  true
                
                
                  ;
                  ViewState[
                
                
                  "
                
                
                  ShowRecordCount
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  true
                
                
                  ;
                   }
                  }
                
              
              
                 return
              
              
                (
              
              
                bool
              
              
                )ViewState[
              
              
                "
              
              
                ShowRecordCount
              
              
                "
              
              
                ];
              
              
                return
              
              
                (
              
              
                bool
              
              
                )ViewState[
              
              
                "
              
              
                ShowRecordCount
              
              
                "
              
              
                ];
                 }
                }
              
            
            
               set
            
            
              set
            
            
               {
              
            
            
            
              
                {
                 ViewState[
              
              
                "
              
              
                ShowRecordCount
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                ViewState[
              
              
                "
              
              
                ShowRecordCount
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                 }
                }
              
            
            
               }
              }
            
          
          
             
             ///
            
            
            
            
              <summary>
            
          
          
          
            
              ///
            
            
            
            
              <summary>
            
            
               ///
            
            
              是否使用默认的样式默认为true
            
            
              ///
            
            
              是否使用默认的样式默认为true
               ///
            
            
            
            
              </summary>
            
            
              ///
            
            
            
            
              </summary>
            
            
            
          
           public
          
          
          
          
            bool
          
          
            bDefaultStyle
          
          
          
            public
          
          
          
          
            bool
          
          
            bDefaultStyle
             {
            
          
          
          
            
              {
               get
            
            
              get
            
            
               {
              
            
            
            
              
                {
                 
                 if
              
              
                (ViewState[
              
              
                "
              
              
                DefaultStyle
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
              
              
                if
              
              
                (ViewState[
              
              
                "
              
              
                DefaultStyle
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
                 {
                
              
              
              
                
                  {
                   ViewState[
                
                
                  "
                
                
                  DefaultStyle
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  true
                
                
                  ;
                  ViewState[
                
                
                  "
                
                
                  DefaultStyle
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  true
                
                
                  ;
                   }
                  }
                
              
              
                 return
              
              
                (
              
              
                bool
              
              
                )ViewState[
              
              
                "
              
              
                DefaultStyle
              
              
                "
              
              
                ];
              
              
                return
              
              
                (
              
              
                bool
              
              
                )ViewState[
              
              
                "
              
              
                DefaultStyle
              
              
                "
              
              
                ];
                 }
                }
              
            
            
               set
            
            
              set
            
            
               {
              
            
            
            
              
                {
                 ViewState[
              
              
                "
              
              
                DefaultStyle
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                ViewState[
              
              
                "
              
              
                DefaultStyle
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                 }
                }
              
            
            
               }
              }
            
          
          
             
             public
          
          
          
          
            string
          
          
            SortExpression
          
          
            public
          
          
          
          
            string
          
          
            SortExpression
             {
            
          
          
          
            
              {
               get
            
            
              get
            
            
               {
              
            
            
            
              
                {
                 if
              
              
                (ViewState[
              
              
                "
              
              
                SortExpression
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
              
              
                if
              
              
                (ViewState[
              
              
                "
              
              
                SortExpression
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
                 {
                
              
              
              
                
                  {
                   ViewState[
                
                
                  "
                
                
                  SortExpression
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  ""
                
                
                  ;
                  ViewState[
                
                
                  "
                
                
                  SortExpression
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  ""
                
                
                  ;
                   }
                  }
                
              
              
                 return
              
              
                (
              
              
                string
              
              
                )ViewState[
              
              
                "
              
              
                SortExpression
              
              
                "
              
              
                ];
              
              
                return
              
              
                (
              
              
                string
              
              
                )ViewState[
              
              
                "
              
              
                SortExpression
              
              
                "
              
              
                ];
                 }
                }
              
            
            
               set
            
            
              set
            
            
               {
              
            
            
            
              
                {
                 ViewState[
              
              
                "
              
              
                SortExpression
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                ViewState[
              
              
                "
              
              
                SortExpression
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                 }
                }
              
            
            
               }
              }
            
          
          
             
             public
          
          
          
          
            bool
          
          
            bIsAccess
          
          
            public
          
          
          
          
            bool
          
          
            bIsAccess
             {
            
          
          
          
            
              {
               get
            
            
              get
            
            
               {
              
            
            
            
              
                {
                 if
              
              
                (ViewState[
              
              
                "
              
              
                IsAccess
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
              
              
                if
              
              
                (ViewState[
              
              
                "
              
              
                IsAccess
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
                 {
                
              
              
              
                
                  {
                   ViewState[
                
                
                  "
                
                
                  IsAccess
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  false
                
                
                  ;
                  ViewState[
                
                
                  "
                
                
                  IsAccess
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  false
                
                
                  ;
                   }
                  }
                
              
              
                 return
              
              
                (
              
              
                bool
              
              
                )ViewState[
              
              
                "
              
              
                IsAccess
              
              
                "
              
              
                ];
              
              
                return
              
              
                (
              
              
                bool
              
              
                )ViewState[
              
              
                "
              
              
                IsAccess
              
              
                "
              
              
                ];
                 }
                }
              
            
            
               set
            
            
              set
            
            
               {
              
            
            
            
              
                {
                 ViewState[
              
              
                "
              
              
                IsAccess
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                ViewState[
              
              
                "
              
              
                IsAccess
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                 }
                }
              
            
            
               }
              }
            
          
          
             
             private
          
          
          
          
            int
          
          
            RecordCount
          
          
            private
          
          
          
          
            int
          
          
            RecordCount
             {
            
          
          
          
            
              {
               get
            
            
              get
            
            
               {
              
            
            
            
              
                {
                 if
              
              
                (ViewState[
              
              
                "
              
              
                RecordCount
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
              
              
                if
              
              
                (ViewState[
              
              
                "
              
              
                RecordCount
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
                 {
                
              
              
              
                
                  {
                   ViewState[
                
                
                  "
                
                
                  RecordCount
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  0
                
                
                  ;
                  ViewState[
                
                
                  "
                
                
                  RecordCount
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  0
                
                
                  ;
                   }
                  }
                
              
              
                 return
              
              
                (
              
              
                int
              
              
                )ViewState[
              
              
                "
              
              
                RecordCount
              
              
                "
              
              
                ];
              
              
                return
              
              
                (
              
              
                int
              
              
                )ViewState[
              
              
                "
              
              
                RecordCount
              
              
                "
              
              
                ];
                 }
                }
              
            
            
               set
            
            
              set
            
            
               {
              
            
            
            
              
                {
                 ViewState[
              
              
                "
              
              
                RecordCount
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                ViewState[
              
              
                "
              
              
                RecordCount
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                 }
                }
              
            
            
               }
              }
            
          
          
             public
          
          
          
          
            string
          
          
            IdentityKey
          
          
            public
          
          
          
          
            string
          
          
            IdentityKey
             {
            
          
          
          
            
              {
               get
            
            
              get
            
            
               {
              
            
            
            
              
                {
                 if
              
              
                (ViewState[
              
              
                "
              
              
                IdentityKey
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
              
              
                if
              
              
                (ViewState[
              
              
                "
              
              
                IdentityKey
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
                 {
                
              
              
              
                
                  {
                   ViewState[
                
                
                  "
                
                
                  IdentityKey
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  ""
                
                
                  ;
                  ViewState[
                
                
                  "
                
                
                  IdentityKey
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  ""
                
                
                  ;
                   }
                  }
                
              
              
                 return
              
              
                (
              
              
                string
              
              
                )ViewState[
              
              
                "
              
              
                IdentityKey
              
              
                "
              
              
                ];
              
              
                return
              
              
                (
              
              
                string
              
              
                )ViewState[
              
              
                "
              
              
                IdentityKey
              
              
                "
              
              
                ];
                 }
                }
              
            
            
               set
            
            
              set
            
            
               {
              
            
            
            
              
                {
                 ViewState[
              
              
                "
              
              
                IdentityKey
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                ViewState[
              
              
                "
              
              
                IdentityKey
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                 }
                }
              
            
            
               }
              }
            
          
          
             private
          
          
          
          
            int
          
          
            PageCount1
          
          
            private
          
          
          
          
            int
          
          
            PageCount1
             {
            
          
          
          
            
              {
               get
            
            
              get
            
            
               {
              
            
            
            
              
                {
                 if
              
              
                (
              
              
                this
              
              
                .Context
              
              
                ==
              
              
              
              
                null
              
              
                )
              
              
                return
              
              
              
              
                0
              
              
                ;
              
              
                if
              
              
                (
              
              
                this
              
              
                .Context
              
              
                ==
              
              
              
              
                null
              
              
                )
              
              
                return
              
              
              
              
                0
              
              
                ;
                 
                 if
              
              
                (
              
              
                this
              
              
                .RecordCount
              
              
                %
              
              
              
              
                this
              
              
                .PageSize
              
              
                ==
              
              
                0
              
              
                )
              
              
                if
              
              
                (
              
              
                this
              
              
                .RecordCount
              
              
                %
              
              
              
              
                this
              
              
                .PageSize
              
              
                ==
              
              
                0
              
              
                )
                 return
              
              
              
              
                this
              
              
                .RecordCount
              
              
                /
              
              
                this
              
              
                .PageSize;
              
              
                return
              
              
              
              
                this
              
              
                .RecordCount
              
              
                /
              
              
                this
              
              
                .PageSize;
                 else
              
              
                else
              
              
                 return
              
              
                Convert.ToInt32(
              
              
                this
              
              
                .RecordCount
              
              
                /
              
              
                this
              
              
                .PageSize)
              
              
                +
              
              
                1
              
              
                ;
              
              
                return
              
              
                Convert.ToInt32(
              
              
                this
              
              
                .RecordCount
              
              
                /
              
              
                this
              
              
                .PageSize)
              
              
                +
              
              
                1
              
              
                ;
                 }
                }
              
            
            
               
               
               }
              }
            
          
          
             
             
             private
          
          
            System.Web.UI.WebControls.DataGridItemobjFooterItem;
          
          
            //
          
          
            footerItem
          
          
            private
          
          
            System.Web.UI.WebControls.DataGridItemobjFooterItem;
          
          
            //
          
          
            footerItem
          
          
             
          
          
             public
          
          
          
          
            string
          
          
            strSQL
          
          
            public
          
          
          
          
            string
          
          
            strSQL
             {
            
          
          
          
            
              {
               get
            
            
              get
            
            
               {
              
            
            
            
              
                {
                 if
              
              
                (ViewState[
              
              
                "
              
              
                strSQL
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
              
              
                if
              
              
                (ViewState[
              
              
                "
              
              
                strSQL
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
                 {
                
              
              
              
                
                  {
                   ViewState[
                
                
                  "
                
                
                  strSQL
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  ""
                
                
                  ;
                  ViewState[
                
                
                  "
                
                
                  strSQL
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  ""
                
                
                  ;
                   }
                  }
                
              
              
                 return
              
              
                (
              
              
                string
              
              
                )ViewState[
              
              
                "
              
              
                strSQL
              
              
                "
              
              
                ];
              
              
                return
              
              
                (
              
              
                string
              
              
                )ViewState[
              
              
                "
              
              
                strSQL
              
              
                "
              
              
                ];
                 }
                }
              
            
            
               set
            
            
              set
            
            
               {
              
            
            
            
              
                {
                 if
              
              
                ((
              
              
                string
              
              
                )value
              
              
                !=
              
              
              
              
                this
              
              
                .strSQL)
              
              
                if
              
              
                ((
              
              
                string
              
              
                )value
              
              
                !=
              
              
              
              
                this
              
              
                .strSQL)
                 {
                
              
              
              
                
                  {
                   this
                
                
                  .CurrentPageNo
                
                
                  =
                
                
                
                
                  1
                
                
                  ;
                
                
                  //
                
                
                  更改了strSQL,重置参数
                
                
                  this
                
                
                  .CurrentPageNo
                
                
                  =
                
                
                
                
                  1
                
                
                  ;
                
                
                  //
                
                
                  更改了strSQL,重置参数
                
                
                   this
                
                
                  .RecordCount
                
                
                  =
                
                
                
                
                  0
                
                
                  ;
                
                
                
                
                  this
                
                
                  .RecordCount
                
                
                  =
                
                
                
                
                  0
                
                
                  ;
                   
                   }
                  }
                
              
              
                 
                 
                 ViewState[
              
              
                "
              
              
                strSQL
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                ViewState[
              
              
                "
              
              
                strSQL
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                 
                 }
                }
              
            
            
               }
              }
            
          
          
             
             public
          
          
          
          
            string
          
          
            ConnectionString
          
          
            public
          
          
          
          
            string
          
          
            ConnectionString
             {
            
          
          
          
            
              {
               get
            
            
              get
            
            
               {
              
            
            
            
              
                {
                 if
              
              
                (ViewState[
              
              
                "
              
              
                ConnectionString
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
              
              
                if
              
              
                (ViewState[
              
              
                "
              
              
                ConnectionString
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
                 {
                
              
              
              
                
                  {
                   ViewState[
                
                
                  "
                
                
                  ConnectionString
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  ""
                
                
                  ;
                  ViewState[
                
                
                  "
                
                
                  ConnectionString
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  ""
                
                
                  ;
                   }
                  }
                
              
              
                 return
              
              
                (
              
              
                string
              
              
                )ViewState[
              
              
                "
              
              
                ConnectionString
              
              
                "
              
              
                ];
              
              
                return
              
              
                (
              
              
                string
              
              
                )ViewState[
              
              
                "
              
              
                ConnectionString
              
              
                "
              
              
                ];
                 }
                }
              
            
            
               set
            
            
              set
            
            
               {
              
            
            
            
              
                {
                 ViewState[
              
              
                "
              
              
                ConnectionString
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                ViewState[
              
              
                "
              
              
                ConnectionString
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                 }
                }
              
            
            
               }
              }
            
          
          
             
             public
          
          
          
          
            string
          
          
            ImagePath
          
          
            public
          
          
          
          
            string
          
          
            ImagePath
             {
            
          
          
          
            
              {
               get
            
            
              get
            
            
               {
              
            
            
            
              
                {
                 if
              
              
                (ViewState[
              
              
                "
              
              
                ImagePath
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
              
              
                if
              
              
                (ViewState[
              
              
                "
              
              
                ImagePath
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
                 {
                
              
              
              
                
                  {
                   ViewState[
                
                
                  "
                
                
                  ImagePath
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  "
                
                
                  ../images/
                
                
                  "
                
                
                  ;
                  ViewState[
                
                
                  "
                
                
                  ImagePath
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  "
                
                
                  ../images/
                
                
                  "
                
                
                  ;
                   }
                  }
                
              
              
                 return
              
              
                (
              
              
                string
              
              
                )ViewState[
              
              
                "
              
              
                ImagePath
              
              
                "
              
              
                ];
              
              
                return
              
              
                (
              
              
                string
              
              
                )ViewState[
              
              
                "
              
              
                ImagePath
              
              
                "
              
              
                ];
                 }
                }
              
            
            
               set
            
            
              set
            
            
               {
              
            
            
            
              
                {
                 ViewState[
              
              
                "
              
              
                ImagePath
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                ViewState[
              
              
                "
              
              
                ImagePath
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                 
                 }
                }
              
            
            
               }
              }
            
          
          
             
             private
          
          
          
          
            string
          
          
            OldSortExpression
          
          
            private
          
          
          
          
            string
          
          
            OldSortExpression
             {
            
          
          
          
            
              {
               get
            
            
              get
            
            
               {
              
            
            
            
              
                {
                 if
              
              
                (ViewState[
              
              
                "
              
              
                OldSortExpression
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
              
              
                if
              
              
                (ViewState[
              
              
                "
              
              
                OldSortExpression
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
                 {
                
              
              
              
                
                  {
                   ViewState[
                
                
                  "
                
                
                  OldSortExpression
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  ""
                
                
                  ;
                  ViewState[
                
                
                  "
                
                
                  OldSortExpression
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  ""
                
                
                  ;
                   }
                  }
                
              
              
                 return
              
              
                (
              
              
                string
              
              
                )ViewState[
              
              
                "
              
              
                OldSortExpression
              
              
                "
              
              
                ];
              
              
                return
              
              
                (
              
              
                string
              
              
                )ViewState[
              
              
                "
              
              
                OldSortExpression
              
              
                "
              
              
                ];
                 }
                }
              
            
            
               set
            
            
              set
            
            
               {
              
            
            
            
              
                {
                 ViewState[
              
              
                "
              
              
                OldSortExpression
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                ViewState[
              
              
                "
              
              
                OldSortExpression
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                 }
                }
              
            
            
               }
              }
            
          
          
             
             public
          
          
          
          
            bool
          
          
            ShowNoRecordMsg
          
          
            public
          
          
          
          
            bool
          
          
            ShowNoRecordMsg
             {
            
          
          
          
            
              {
               get
            
            
              get
            
            
               {
              
            
            
            
              
                {
                 if
              
              
                (ViewState[
              
              
                "
              
              
                ShowNoRecordMsg
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
              
              
                if
              
              
                (ViewState[
              
              
                "
              
              
                ShowNoRecordMsg
              
              
                "
              
              
                ]
              
              
                ==
              
              
                null
              
              
                )
                 {
                
              
              
              
                
                  {
                   ViewState[
                
                
                  "
                
                
                  ShowNoRecordMsg
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  true
                
                
                  ;
                  ViewState[
                
                
                  "
                
                
                  ShowNoRecordMsg
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  true
                
                
                  ;
                   }
                  }
                
              
              
                 return
              
              
                (
              
              
                bool
              
              
                )ViewState[
              
              
                "
              
              
                ShowNoRecordMsg
              
              
                "
              
              
                ];
              
              
                return
              
              
                (
              
              
                bool
              
              
                )ViewState[
              
              
                "
              
              
                ShowNoRecordMsg
              
              
                "
              
              
                ];
                 }
                }
              
            
            
               set
            
            
              set
            
            
               {
              
            
            
            
              
                {
                 ViewState[
              
              
                "
              
              
                ShowNoRecordMsg
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                ViewState[
              
              
                "
              
              
                ShowNoRecordMsg
              
              
                "
              
              
                ]
              
              
                =
              
              
                value;
                 }
                }
              
            
            
               }
              }
            
          
          
             
             
             
             
             
             
             
             
             private
          
          
          
          
            string
          
          
            GetStyleString()
          
          
            private
          
          
          
          
            string
          
          
            GetStyleString()
             {
            
          
          
          
            
              {
               string
            
            
              res
            
            
              =
            
            
              ""
            
            
              ;
            
            
              string
            
            
              res
            
            
              =
            
            
              ""
            
            
              ;
               foreach
            
            
              (
            
            
              string
            
            
              sKey
            
            
              in
            
            
            
            
              this
            
            
              .Style.Keys)
            
            
              foreach
            
            
              (
            
            
              string
            
            
              sKey
            
            
              in
            
            
            
            
              this
            
            
              .Style.Keys)
               {
              
            
            
            
              
                {
                 res
              
              
                +=
              
              
                sKey
              
              
                +
              
              
                "
              
              
                :
              
              
                "
              
              
                +
              
              
              
              
                this
              
              
                .Style[sKey]
              
              
                +
              
              
                "
              
              
                ;
              
              
                "
              
              
                ;
                res
              
              
                +=
              
              
                sKey
              
              
                +
              
              
                "
              
              
                :
              
              
                "
              
              
                +
              
              
              
              
                this
              
              
                .Style[sKey]
              
              
                +
              
              
                "
              
              
                ;
              
              
                "
              
              
                ;
                 }
                }
              
            
            
               return
            
            
              res;
            
            
              return
            
            
              res;
               
               
               
               }
              }
            
          
          
             
             
             
             
             protected
          
          
          
          
            override
          
          
          
          
            void
          
          
            OnSortCommand(DataGridSortCommandEventArgse)
          
          
            protected
          
          
          
          
            override
          
          
          
          
            void
          
          
            OnSortCommand(DataGridSortCommandEventArgse)
             {
            
          
          
          
            
              {
               
               
               string
            
            
              sSort
            
            
              =
            
            
              e.SortExpression.Trim();
            
            
              string
            
            
              sSort
            
            
              =
            
            
              e.SortExpression.Trim();
               if
            
            
              (
            
            
              this
            
            
              .SortExpression.Trim().Split(
            
            
              '
            
            
            
            
              '
            
            
              )[
            
            
              0
            
            
              ]
            
            
              ==
            
            
              e.SortExpression)
            
            
              if
            
            
              (
            
            
              this
            
            
              .SortExpression.Trim().Split(
            
            
              '
            
            
            
            
              '
            
            
              )[
            
            
              0
            
            
              ]
            
            
              ==
            
            
              e.SortExpression)
               {
              
            
            
            
              
                {
                 sSort
              
              
                =
              
              
              
              
                this
              
              
                .SortExpression;
                sSort
              
              
                =
              
              
              
              
                this
              
              
                .SortExpression;
                 }
                }
              
            
            
               
               string
            
            
              direct
            
            
              =
            
            
              "
            
            
              ASC
            
            
              "
            
            
              ;
            
            
              string
            
            
              direct
            
            
              =
            
            
              "
            
            
              ASC
            
            
              "
            
            
              ;
               if
            
            
              (sSort.IndexOf(
            
            
              "
            
            
            
            
              "
            
            
              )
            
            
              >-
            
            
              1
            
            
              )
            
            
              if
            
            
              (sSort.IndexOf(
            
            
              "
            
            
            
            
              "
            
            
              )
            
            
              >-
            
            
              1
            
            
              )
               {
              
            
            
            
              
                {
                 direct
              
              
                =
              
              
                sSort.Split(
              
              
                '
              
              
              
              
                '
              
              
                )[
              
              
                1
              
              
                ];
                direct
              
              
                =
              
              
                sSort.Split(
              
              
                '
              
              
              
              
                '
              
              
                )[
              
              
                1
              
              
                ];
                 
                 
                 if
              
              
                (direct.ToUpper()
              
              
                ==
              
              
                "
              
              
                ASC
              
              
                "
              
              
                )
              
              
                if
              
              
                (direct.ToUpper()
              
              
                ==
              
              
                "
              
              
                ASC
              
              
                "
              
              
                )
                 {
                
              
              
              
                
                  {
                   direct
                
                
                  =
                
                
                  "
                
                
                  DESC
                
                
                  "
                
                
                  ;
                  direct
                
                
                  =
                
                
                  "
                
                
                  DESC
                
                
                  "
                
                
                  ;
                   
                   
                   }
                  }
                
              
              
                 else
              
              
                else
              
              
                 {
                
              
              
              
                
                  {
                   direct
                
                
                  =
                
                
                  "
                
                
                  ASC
                
                
                  "
                
                
                  ;
                  direct
                
                
                  =
                
                
                  "
                
                
                  ASC
                
                
                  "
                
                
                  ;
                   
                   }
                  }
                
              
              
                 
                 
                 }
                }
              
            
            
               
               
               sSort
            
            
              =
            
            
              sSort.Split(
            
            
              '
            
            
            
            
              '
            
            
              )[
            
            
              0
            
            
              ]
            
            
              +
            
            
              "
            
            
            
            
              "
            
            
              +
            
            
              direct;
              sSort
            
            
              =
            
            
              sSort.Split(
            
            
              '
            
            
            
            
              '
            
            
              )[
            
            
              0
            
            
              ]
            
            
              +
            
            
              "
            
            
            
            
              "
            
            
              +
            
            
              direct;
               
               if
            
            
              (
            
            
              this
            
            
              .OldSortExpression
            
            
              !=
            
            
              ""
            
            
              )
            
            
              if
            
            
              (
            
            
              this
            
            
              .OldSortExpression
            
            
              !=
            
            
              ""
            
            
              )
               {
              
            
            
            
              
                {
                 DataGridColumnoOldCol
              
              
                =
              
              
              
              
                this
              
              
                .GetColumnBySortExpression(
              
              
                this
              
              
                .OldSortExpression);
                DataGridColumnoOldCol
              
              
                =
              
              
              
              
                this
              
              
                .GetColumnBySortExpression(
              
              
                this
              
              
                .OldSortExpression);
                 oOldCol.HeaderText
              
              
                =
              
              
                oOldCol.HeaderText.Split(
              
              
                '
              
              
              
              
                '
              
              
                )[
              
              
                0
              
              
                ];
                oOldCol.HeaderText
              
              
                =
              
              
                oOldCol.HeaderText.Split(
              
              
                '
              
              
              
              
                '
              
              
                )[
              
              
                0
              
              
                ];
                 }
                }
              
            
            
               
               DataGridColumncol
            
            
              =
            
            
              GetColumnBySortExpression(e.SortExpression);
              DataGridColumncol
            
            
              =
            
            
              GetColumnBySortExpression(e.SortExpression);
               
               if
            
            
              (direct
            
            
              ==
            
            
              "
            
            
              ASC
            
            
              "
            
            
              )
            
            
              if
            
            
              (direct
            
            
              ==
            
            
              "
            
            
              ASC
            
            
              "
            
            
              )
               {
              
            
            
            
              
                {
                 col.HeaderText
              
              
                =
              
              
                col.HeaderText.Split(
              
              
                '
              
              
              
              
                '
              
              
                )[
              
              
                0
              
              
                ]
              
              
                +
              
              
                "
              
              
                <fontclass='gridarrow'face='webdings'>5</font>
              
              
                "
              
              
                ;
                col.HeaderText
              
              
                =
              
              
                col.HeaderText.Split(
              
              
                '
              
              
              
              
                '
              
              
                )[
              
              
                0
              
              
                ]
              
              
                +
              
              
                "
              
              
                <fontclass='gridarrow'face='webdings'>5</font>
              
              
                "
              
              
                ;
                 }
                }
              
            
            
               else
            
            
              else
            
            
               {
              
            
            
            
              
                {
                 col.HeaderText
              
              
                =
              
              
                col.HeaderText.Split(
              
              
                '
              
              
              
              
                '
              
              
                )[
              
              
                0
              
              
                ]
              
              
                +
              
              
                "
              
              
                <fontclass='gridarrow'face='webdings'>6</font>
              
              
                "
              
              
                ;
                col.HeaderText
              
              
                =
              
              
                col.HeaderText.Split(
              
              
                '
              
              
              
              
                '
              
              
                )[
              
              
                0
              
              
                ]
              
              
                +
              
              
                "
              
              
                <fontclass='gridarrow'face='webdings'>6</font>
              
              
                "
              
              
                ;
                 }
                }
              
            
            
               this
            
            
              .OldSortExpression
            
            
              =
            
            
              e.SortExpression;
            
            
              this
            
            
              .OldSortExpression
            
            
              =
            
            
              e.SortExpression;
               this
            
            
              .SortExpression
            
            
              =
            
            
              sSort;
            
            
              this
            
            
              .SortExpression
            
            
              =
            
            
              sSort;
               this
            
            
              .DataBind();
            
            
              this
            
            
              .DataBind();
               }
              }
            
          
          
             
             private
          
          
            DataGridColumnGetColumnBySortExpression(
          
          
            string
          
          
            sort)
          
          
            private
          
          
            DataGridColumnGetColumnBySortExpression(
          
          
            string
          
          
            sort)
             {
            
          
          
          
            
              {
               for
            
            
              (
            
            
              int
            
            
              i
            
            
              =
            
            
              0
            
            
              ;i
            
            
              <
            
            
              this
            
            
              .Columns.Count;i
            
            
              ++
            
            
              )
            
            
              for
            
            
              (
            
            
              int
            
            
              i
            
            
              =
            
            
              0
            
            
              ;i
            
            
              <
            
            
              this
            
            
              .Columns.Count;i
            
            
              ++
            
            
              )
               {
              
            
            
            
              
                {
                 if
              
              
                (
              
              
                this
              
              
                .Columns[i].SortExpression
              
              
                ==
              
              
                sort.Split(
              
              
                '
              
              
              
              
                '
              
              
                )[
              
              
                0
              
              
                ])
              
              
                if
              
              
                (
              
              
                this
              
              
                .Columns[i].SortExpression
              
              
                ==
              
              
                sort.Split(
              
              
                '
              
              
              
              
                '
              
              
                )[
              
              
                0
              
              
                ])
                 {
                
              
              
              
                
                  {
                   return
                
                
                
                
                  this
                
                
                  .Columns[i];
                
                
                  return
                
                
                
                
                  this
                
                
                  .Columns[i];
                   }
                  }
                
              
              
                 }
                }
              
            
            
               
               return
            
            
            
            
              null
            
            
              ;
            
            
              return
            
            
            
            
              null
            
            
              ;
               }
              }
            
          
          
             
             
             
             
             
             
             protected
          
          
          
          
            override
          
          
          
          
            void
          
          
            OnItemCreated(DataGridItemEventArgse)
          
          
            protected
          
          
          
          
            override
          
          
          
          
            void
          
          
            OnItemCreated(DataGridItemEventArgse)
             {
            
          
          
          
            
              {
               
               
               
               if
            
            
              (e.Item.ItemType
            
            
              ==
            
            
              ListItemType.Footer)
            
            
              if
            
            
              (e.Item.ItemType
            
            
              ==
            
            
              ListItemType.Footer)
               {
              
            
            
            
              
                {
                 
                 this
              
              
                .objFooterItem
              
              
                =
              
              
                e.Item;
              
              
                //
              
              
                将它保存下来,目前还不能取得它的Visible属性,最后再处理
              
              
                this
              
              
                .objFooterItem
              
              
                =
              
              
                e.Item;
              
              
                //
              
              
                将它保存下来,目前还不能取得它的Visible属性,最后再处理
              
              
                 
              
              
                 
                 }
                }
              
            
            
               else
            
            
            
            
              if
            
            
              (e.Item.ItemType
            
            
              ==
            
            
              ListItemType.Item
            
            
              else
            
            
            
            
              if
            
            
              (e.Item.ItemType
            
            
              ==
            
            
              ListItemType.Item
               ||
            
            
              e.Item.ItemType
            
            
              ==
            
            
              ListItemType.AlternatingItem)
            
            
              ||
            
            
              e.Item.ItemType
            
            
              ==
            
            
              ListItemType.AlternatingItem)
               {
              
            
            
            
              
                {
                 e.Item.Attributes.Add(
              
              
                "
              
              
                onmouseover
              
              
                "
              
              
                ,
              
              
                "
              
              
                javascript:returnDataGridOnMouseOver();
              
              
                "
              
              
                );
                e.Item.Attributes.Add(
              
              
                "
              
              
                onmouseover
              
              
                "
              
              
                ,
              
              
                "
              
              
                javascript:returnDataGridOnMouseOver();
              
              
                "
              
              
                );
                 e.Item.Attributes.Add(
              
              
                "
              
              
                onmouseout
              
              
                "
              
              
                ,
              
              
                "
              
              
                javascript:returnDataGridOnMouseOut();
              
              
                "
              
              
                );
                e.Item.Attributes.Add(
              
              
                "
              
              
                onmouseout
              
              
                "
              
              
                ,
              
              
                "
              
              
                javascript:returnDataGridOnMouseOut();
              
              
                "
              
              
                );
                 
                 }
                }
              
            
            
               
               base
            
            
              .OnItemCreated(e);
            
            
              base
            
            
              .OnItemCreated(e);
               }
              }
            
          
          
             
             
             
             
             
             
             private
          
          
          
          
            string
          
          
            GetPagerText()
          
          
            private
          
          
          
          
            string
          
          
            GetPagerText()
             {
            
          
          
          
            
              {
               
               string
            
            
              res
            
            
              =
            
            
            
            
              @"
            
            
              <!--{3}-->
            
            
              string
            
            
              res
            
            
              =
            
            
            
            
              @"
            
            
              <!--{3}-->
               <tablealign='right'>
              <tablealign='right'>
               <TR>
              <TR>
               <TD>
              <TD>
               <span{0}{9}title='回到首页'onclick=""if(this.disabled)return;hidAction_{2}.value='1';btnPager_{2}.click();""style='CURSOR:hand;;border:solid1px#ffffff;padding-right:2px;'><fontface='webdings'>7</font>[首页]</span>
              <span{0}{9}title='回到首页'onclick=""if(this.disabled)return;hidAction_{2}.value='1';btnPager_{2}.click();""style='CURSOR:hand;;border:solid1px#ffffff;padding-right:2px;'><fontface='webdings'>7</font>[首页]</span>
               </TD>
              </TD>
               <TD>
              <TD>
               <span{0}{9}title='回到上一页'onclick=""if(this.disabled)return;hidAction_{2}.value='2';btnPager_{2}.click();""style='CURSOR:hand;border:solid1px#ffffff;padding-right:2px;'><fontface='webdings'>3</font>上页</span>
              <span{0}{9}title='回到上一页'onclick=""if(this.disabled)return;hidAction_{2}.value='2';btnPager_{2}.click();""style='CURSOR:hand;border:solid1px#ffffff;padding-right:2px;'><fontface='webdings'>3</font>上页</span>
               </TD>
              </TD>
               <TD>
              <TD>
               <span{1}{9}title='回到下一页'onclick=""if(this.disabled)return;hidAction_{2}.value='3';btnPager_{2}.click();""style='CURSOR:hand;border:solid1px#ffffff;padding-right:2px;'>下页<fontface='webdings'>4</font></span>
              <span{1}{9}title='回到下一页'onclick=""if(this.disabled)return;hidAction_{2}.value='3';btnPager_{2}.click();""style='CURSOR:hand;border:solid1px#ffffff;padding-right:2px;'>下页<fontface='webdings'>4</font></span>
               </TD>
              </TD>
               <TD>
              <TD>
               <span{1}{9}title='回到最后一页'onclick=""if(this.disabled)return;hidAction_{2}.value='4';btnPager_{2}.click();""style='CURSOR:hand;border:solid1px#ffffff;padding-right:2px;'>[末页]<fontface='webdings'>8</font></span>
              <span{1}{9}title='回到最后一页'onclick=""if(this.disabled)return;hidAction_{2}.value='4';btnPager_{2}.click();""style='CURSOR:hand;border:solid1px#ffffff;padding-right:2px;'>[末页]<fontface='webdings'>8</font></span>
               </TD>
              </TD>
               <TD>
              <TD>
               <spanid='lblCurrentIndex'style='CURSOR:hand'>[{4}/{8}页]</span>
              <spanid='lblCurrentIndex'style='CURSOR:hand'>[{4}/{8}页]</span>
               </TD><TD>
              </TD><TD>
               <spanid='tbl1'style='CURSOR:hand;height:20px;border:solid0px#e0e0e0;padding:2px;'></TD><TD>{10}</TD><TD>跳到</TD><TD></span><inputname='txtGoPage_{2}'value='{7}'type='text'id='txtGoPage'class='textbox1'style='width:20px;height:18px'/>
              <spanid='tbl1'style='CURSOR:hand;height:20px;border:solid0px#e0e0e0;padding:2px;'></TD><TD>{10}</TD><TD>跳到</TD><TD></span><inputname='txtGoPage_{2}'value='{7}'type='text'id='txtGoPage'class='textbox1'style='width:20px;height:18px'/>
               </TD><TD><INPUTclass='btnPager'onclick=""hidAction_{2}.value='5';btnPager_{2}.click();""type=buttonvalue='GO'></TD><TD>
              </TD><TD><INPUTclass='btnPager'onclick=""hidAction_{2}.value='5';btnPager_{2}.click();""type=buttonvalue='GO'></TD><TD>
               <spanid='tbl2'style='CURSOR:hand;height:20px;border:solid0px#e0e0e0;padding:2px;'>每页显示</span></TD><TD><inputname='txtRowsPager_{2}'type='text'id='txtRowsPager'value='{5}'class='textbox1'style='width:20px;height:18px'/></TD><TD><INPUTclass='btnPager'onclick=""hidAction_{2}.value='6';btnPager_{2}.click();""type=buttonvalue=重置>
              <spanid='tbl2'style='CURSOR:hand;height:20px;border:solid0px#e0e0e0;padding:2px;'>每页显示</span></TD><TD><inputname='txtRowsPager_{2}'type='text'id='txtRowsPager'value='{5}'class='textbox1'style='width:20px;height:18px'/></TD><TD><INPUTclass='btnPager'onclick=""hidAction_{2}.value='6';btnPager_{2}.click();""type=buttonvalue=重置>
               </TD><TD><inputname='hidAction_{2}'id='hidAction_{2}'type='hidden'/>
            
            
              "
            
            
              ;
              </TD><TD><inputname='hidAction_{2}'id='hidAction_{2}'type='hidden'/>
            
            
              "
            
            
              ;
               if
            
            
              (
            
            
              this
            
            
              .Context
            
            
              !=
            
            
            
            
              null
            
            
              )
            
            
              //
            
            
              非设计视图
            
            
              if
            
            
              (
            
            
              this
            
            
              .Context
            
            
              !=
            
            
            
            
              null
            
            
              )
            
            
              //
            
            
              非设计视图
            
            
               {
              
            
            
            
            
            
              
                {
                 res
              
              
                +=
              
              
              
              
                @"
                res
              
              
                +=
              
              
              
              
                @"
              
              
                 <inputtype='button'name='btnPager_{2}'id='btnPager_{2}'{6}value='Button'id='btnPager_{2}'style='DISPLAY:none'/>
              
              
                "
              
              
                ;
                <inputtype='button'name='btnPager_{2}'id='btnPager_{2}'{6}value='Button'id='btnPager_{2}'style='DISPLAY:none'/>
              
              
                "
              
              
                ;
                 }
                }
              
            
            
               res
            
            
              +=
            
            
              @"
            
            
              </TD><TD>
              res
            
            
              +=
            
            
              @"
            
            
              </TD><TD>
               </TR></TABLE>
            
            
              "
            
            
              ;
              </TR></TABLE>
            
            
              "
            
            
              ;
               
               
               
               
               //
            
            
              System.Web.HttpContext.Current.Response.Write(System.Web.HttpContext.Current.Server.HtmlEncode(res));
            
            
              //
            
            
              System.Web.HttpContext.Current.Response.Write(System.Web.HttpContext.Current.Server.HtmlEncode(res));
               //
            
            
              System.Web.HttpContext.Current.Response.Flush();
            
            
              //
            
            
              System.Web.HttpContext.Current.Response.Flush();
            
            
               string
            
            
              sP0
            
            
              =
            
            
            
            
              this
            
            
              .CurrentPageNo
            
            
              >
            
            
            
            
              1
            
            
            
            
              ?
            
            
              ""
            
            
              :
            
            
              "
            
            
              disabled
            
            
              "
            
            
              ;
            
            
            
            
              string
            
            
              sP0
            
            
              =
            
            
            
            
              this
            
            
              .CurrentPageNo
            
            
              >
            
            
            
            
              1
            
            
            
            
              ?
            
            
              ""
            
            
              :
            
            
              "
            
            
              disabled
            
            
              "
            
            
              ;
               string
            
            
              sP1
            
            
              =
            
            
            
            
              this
            
            
              .CurrentPageNo
            
            
              <
            
            
            
            
              this
            
            
              .PageCount1
            
            
              ?
            
            
              ""
            
            
              :
            
            
              "
            
            
              disabled
            
            
              "
            
            
              ;
            
            
              string
            
            
              sP1
            
            
              =
            
            
            
            
              this
            
            
              .CurrentPageNo
            
            
              <
            
            
            
            
              this
            
            
              .PageCount1
            
            
              ?
            
            
              ""
            
            
              :
            
            
              "
            
            
              disabled
            
            
              "
            
            
              ;
               string
            
            
              sP2
            
            
              =
            
            
            
            
              this
            
            
              .ID;
            
            
              string
            
            
              sP2
            
            
              =
            
            
            
            
              this
            
            
              .ID;
               string
            
            
              sP3
            
            
              =
            
            
            
            
              this
            
            
              .ImagePath;
            
            
              string
            
            
              sP3
            
            
              =
            
            
            
            
              this
            
            
              .ImagePath;
               string
            
            
              sP4
            
            
              =
            
            
            
            
              "
            
            
              <fontcolor='red'>
            
            
              "
            
            
              +
            
            
              this
            
            
              .CurrentPageNo.ToString()
            
            
              +
            
            
              "
            
            
              </font>
            
            
              "
            
            
              ;
            
            
              string
            
            
              sP4
            
            
              =
            
            
            
            
              "
            
            
              <fontcolor='red'>
            
            
              "
            
            
              +
            
            
              this
            
            
              .CurrentPageNo.ToString()
            
            
              +
            
            
              "
            
            
              </font>
            
            
              "
            
            
              ;
               string
            
            
              sP5
            
            
              =
            
            
            
            
              this
            
            
              .PageSize.ToString();
            
            
              string
            
            
              sP5
            
            
              =
            
            
            
            
              this
            
            
              .PageSize.ToString();
               string
            
            
              sP6
            
            
              =
            
            
            
            
              "
            
            
              onclick="javascript:
            
            
              "
            
            
              +
            
            
              this
            
            
              .Page.GetPostBackEventReference(
            
            
              this
            
            
              ,
            
            
              "
            
            
              btnPager_
            
            
              "
            
            
              +
            
            
              sP2)
            
            
              +
            
            
              "
            
            
              "
            
            
              "
            
            
              ;
            
            
              string
            
            
              sP6
            
            
              =
            
            
            
            
              "
            
            
              onclick="javascript:
            
            
              "
            
            
              +
            
            
              this
            
            
              .Page.GetPostBackEventReference(
            
            
              this
            
            
              ,
            
            
              "
            
            
              btnPager_
            
            
              "
            
            
              +
            
            
              sP2)
            
            
              +
            
            
              "
            
            
              "
            
            
              "
            
            
              ;
               string
            
            
              sP7
            
            
              =
            
            
            
            
              this
            
            
              .CurrentPageNo.ToString();
            
            
              string
            
            
              sP7
            
            
              =
            
            
            
            
              this
            
            
              .CurrentPageNo.ToString();
               //
            
            
              System.Web.HttpContext.Current.Response.Write(this.PageCount1+"**");
            
            
              //
            
            
              System.Web.HttpContext.Current.Response.Write(this.PageCount1+"**");
            
            
               
            
            
               string
            
            
              sP8
            
            
              =
            
            
            
            
              "
            
            
              <fontcolor='red'>
            
            
              "
            
            
              +
            
            
              this
            
            
              .PageCount1.ToString()
            
            
              +
            
            
              "
            
            
              </font>
            
            
              "
            
            
              ;
            
            
              string
            
            
              sP8
            
            
              =
            
            
            
            
              "
            
            
              <fontcolor='red'>
            
            
              "
            
            
              +
            
            
              this
            
            
              .PageCount1.ToString()
            
            
              +
            
            
              "
            
            
              </font>
            
            
              "
            
            
              ;
               string
            
            
              sP9
            
            
              =
            
            
            
            
              "
            
            
              onmouseover='javascript:{0}_PagerOnMouseOver(this);'onmouseout='javascript:{0}_PagerOnMouseOut(this);'onmousedown='javascript:{0}_PagerOnMouseDown(this);'onmouseup='javascript:{0}_PagerOnMouseUp(this);'
            
            
              "
            
            
              ;
            
            
              string
            
            
              sP9
            
            
              =
            
            
            
            
              "
            
            
              onmouseover='javascript:{0}_PagerOnMouseOver(this);'onmouseout='javascript:{0}_PagerOnMouseOut(this);'onmousedown='javascript:{0}_PagerOnMouseDown(this);'onmouseup='javascript:{0}_PagerOnMouseUp(this);'
            
            
              "
            
            
              ;
               string
            
            
              sP10
            
            
              =
            
            
            
            
              ""
            
            
              ;
            
            
              string
            
            
              sP10
            
            
              =
            
            
            
            
              ""
            
            
              ;
               if
            
            
              (
            
            
              this
            
            
              .ShowRecordCount)
            
            
              //
            
            
              显示记录数
            
            
              if
            
            
              (
            
            
              this
            
            
              .ShowRecordCount)
            
            
              //
            
            
              显示记录数
            
            
               {
              
            
            
            
            
            
              
                {
                 sP10
              
              
                =
              
              
              
              
                "
              
              
                [<fontcolor='red'>
              
              
                "
                sP10
              
              
                =
              
              
              
              
                "
              
              
                [<fontcolor='red'>
              
              
                "
              
              
                 +
              
              
                (((
              
              
                this
              
              
                .CurrentPageNo
              
              
                -
              
              
                1
              
              
                )
              
              
                *
              
              
              
              
                this
              
              
                .PageSize)
              
              
                +
              
              
                1
              
              
                ).ToString()
              
              
                +
              
              
                "
              
              
                </font>-<fontcolor='red'>
              
              
                "
              
              
                +
              
              
                (((
              
              
                this
              
              
                .CurrentPageNo
              
              
                -
              
              
                1
              
              
                )
              
              
                *
              
              
              
              
                this
              
              
                .PageSize)
              
              
                +
              
              
                1
              
              
                ).ToString()
              
              
                +
              
              
                "
              
              
                </font>-<fontcolor='red'>
              
              
                "
              
              
                 +
              
              
                (
              
              
                this
              
              
                .CurrentPageNo
              
              
                *
              
              
                this
              
              
                .PageSize
              
              
                <
              
              
                this
              
              
                .RecordCount
              
              
                ?
              
              
                this
              
              
                .CurrentPageNo
              
              
                *
              
              
                this
              
              
                .PageSize:
              
              
                this
              
              
                .RecordCount).ToString()
              
              
                +
              
              
                "
              
              
                </font>/<fontcolor='red'>
              
              
                "
              
              
                +
              
              
                this
              
              
                .RecordCount.ToString()
              
              
                +
              
              
                "
              
              
                </font>条]
              
              
                "
              
              
                ;
              
              
                +
              
              
                (
              
              
                this
              
              
                .CurrentPageNo
              
              
                *
              
              
                this
              
              
                .PageSize
              
              
                <
              
              
                this
              
              
                .RecordCount
              
              
                ?
              
              
                this
              
              
                .CurrentPageNo
              
              
                *
              
              
                this
              
              
                .PageSize:
              
              
                this
              
              
                .RecordCount).ToString()
              
              
                +
              
              
                "
              
              
                </font>/<fontcolor='red'>
              
              
                "
              
              
                +
              
              
                this
              
              
                .RecordCount.ToString()
              
              
                +
              
              
                "
              
              
                </font>条]
              
              
                "
              
              
                ;
                 }
                }
              
            
            
               sP9
            
            
              =
            
            
              String.Format(sP9,sP2);
              sP9
            
            
              =
            
            
              String.Format(sP9,sP2);
               res
            
            
              =
            
            
              String.Format(res,sP0,sP1,sP2,sP3,sP4,sP5,sP6,sP7,sP8,sP9,sP10);
              res
            
            
              =
            
            
              String.Format(res,sP0,sP1,sP2,sP3,sP4,sP5,sP6,sP7,sP8,sP9,sP10);
               
               
               string
            
            
              res1
            
            
              =
            
            
            
            
              @"
            
            
              string
            
            
              res1
            
            
              =
            
            
            
            
              @"
            
            
               <SCRIPTLANGUAGE='javascript'>
              <SCRIPTLANGUAGE='javascript'>
               <!--
              <!--
               function{0}_PagerOnMouseOver(obj)
              function{0}_PagerOnMouseOver(obj)
               {
              {
               if(obj.disabled)return;obj.runtimeStyle.cssText='border-right:solid1pxgray;border-bottom:solid1pxgray';
              if(obj.disabled)return;obj.runtimeStyle.cssText='border-right:solid1pxgray;border-bottom:solid1pxgray';
               }
              }
               function{0}_PagerOnMouseOut(obj)
              function{0}_PagerOnMouseOut(obj)
               {
              {
               if(obj.disabled)return;obj.runtimeStyle.cssText='';
              if(obj.disabled)return;obj.runtimeStyle.cssText='';
               }
              }
               function{0}_PagerOnMouseDown(obj)
              function{0}_PagerOnMouseDown(obj)
               {
              {
               if(obj.disabled)return;
              if(obj.disabled)return;
               obj.runtimeStyle.cssText='border-bottom:solid1pxwhite;border-right:solid1pxwhite;border-top:solid1pxgray;border-left:solid1pxgray;';
              obj.runtimeStyle.cssText='border-bottom:solid1pxwhite;border-right:solid1pxwhite;border-top:solid1pxgray;border-left:solid1pxgray;';
               }
              }
               function{0}_PagerOnMouseUp(obj)
              function{0}_PagerOnMouseUp(obj)
               {
              {
               if(obj.disabled)return;obj.runtimeStyle.cssText='border-top:solid1pxwhite;border-left:solid1pxwhite;border-bottom:solid1pxgray;border-right:solid1pxgray;';
              if(obj.disabled)return;obj.runtimeStyle.cssText='border-top:solid1pxwhite;border-left:solid1pxwhite;border-bottom:solid1pxgray;border-right:solid1pxgray;';
               }
              }
               //-->
              //-->
               </SCRIPT>
              </SCRIPT>
               <!--********************************************--->
              <!--********************************************--->
               "
            
            
              ;
            
            
              "
            
            
              ;
               //
            
            
              res1=String.Format(res1,sP2);
            
            
              //
            
            
              res1=String.Format(res1,sP2);
            
            
               res1
            
            
              =
            
            
              res1.Replace(
            
            
              "
            
            
              {0}
            
            
              "
            
            
              ,sP2);
            
            
              res1
            
            
              =
            
            
              res1.Replace(
            
            
              "
            
            
              {0}
            
            
              "
            
            
              ,sP2);
               return
            
            
              res
            
            
              +
            
            
              res1;
            
            
              return
            
            
              res
            
            
              +
            
            
              res1;
               }
              }
            
          
          
             
             
             protected
          
          
          
          
            override
          
          
          
          
            void
          
          
            OnPreRender(EventArgse)
          
          
            protected
          
          
          
          
            override
          
          
          
          
            void
          
          
            OnPreRender(EventArgse)
             {
            
          
          
          
            
              {
               //
            
            
              base.OnPreRender(e);
            
            
              //
            
            
              base.OnPreRender(e);
               //
            
            
              return;
            
            
              //
            
            
              return;
            
            
               if
            
            
              (bDefaultStyle)
            
            
              //
            
            
              默认的样式
            
            
            
            
              if
            
            
              (bDefaultStyle)
            
            
              //
            
            
              默认的样式
            
            
               {
              
            
            
            
            
            
              
                {
                 this
              
              
                .BorderColor
              
              
                =
              
              
                (Color)
              
              
                new
              
              
                System.Drawing.ColorConverter().ConvertFromString(
              
              
                "
              
              
                #E3EDF5
              
              
                "
              
              
                );
              
              
                this
              
              
                .BorderColor
              
              
                =
              
              
                (Color)
              
              
                new
              
              
                System.Drawing.ColorConverter().ConvertFromString(
              
              
                "
              
              
                #E3EDF5
              
              
                "
              
              
                );
                 this
              
              
                .Attributes[
              
              
                "
              
              
                Class
              
              
                "
              
              
                ]
              
              
                =
              
              
              
              
                "
              
              
                GridTable
              
              
                "
              
              
                ;
              
              
                this
              
              
                .Attributes[
              
              
                "
              
              
                Class
              
              
                "
              
              
                ]
              
              
                =
              
              
              
              
                "
              
              
                GridTable
              
              
                "
              
              
                ;
                 }
              
            
            
              //
            
            
              处理FoooterItem
                }
              
            
            
              //
            
            
              处理FoooterItem
               //
            
            
              找到第一个Visible=True的列
            
            
              //
            
            
              找到第一个Visible=True的列
            
            
               if
            
            
              (
            
            
              this
            
            
              .objFooterItem
            
            
              !=
            
            
            
            
              null
            
            
              )
            
            
            
            
              if
            
            
              (
            
            
              this
            
            
              .objFooterItem
            
            
              !=
            
            
            
            
              null
            
            
              )
               {
              
            
            
            
              
                {
                 int
              
              
                i
              
              
                =
              
              
              
              
                0
              
              
                ;
              
              
                int
              
              
                i
              
              
                =
              
              
              
              
                0
              
              
                ;
                 for
              
              
                (i
              
              
                =
              
              
              
              
                0
              
              
                ;i
              
              
                <
              
              
              
              
                this
              
              
                .Columns.Count;i
              
              
                ++
              
              
                )
              
              
                for
              
              
                (i
              
              
                =
              
              
              
              
                0
              
              
                ;i
              
              
                <
              
              
              
              
                this
              
              
                .Columns.Count;i
              
              
                ++
              
              
                )
                 {
                
              
              
              
                
                  {
                   if
                
                
                  (
                
                
                  this
                
                
                  .Columns[i].Visible)
                
                
                  if
                
                
                  (
                
                
                  this
                
                
                  .Columns[i].Visible)
                   {
                  
                
                
                
                  
                    {
                     break
                  
                  
                    ;
                  
                  
                    break
                  
                  
                    ;
                     }
                    }
                  
                
                
                   }
                  }
                
              
              
                 
                 
                 while
              
              
                (
              
              
                this
              
              
                .objFooterItem.Cells.Count
              
              
                >
              
              
                i
              
              
                +
              
              
                1
              
              
                )
              
              
                while
              
              
                (
              
              
                this
              
              
                .objFooterItem.Cells.Count
              
              
                >
              
              
                i
              
              
                +
              
              
                1
              
              
                )
                 {
                
              
              
              
                
                  {
                   objFooterItem.Cells.RemoveAt(
                
                
                  0
                
                
                  );
                  objFooterItem.Cells.RemoveAt(
                
                
                  0
                
                
                  );
                   }
                  }
                
              
              
                 objFooterItem.Cells[i].ColumnSpan
              
              
                =
              
              
              
              
                this
              
              
                .Columns.Count
              
              
                -
              
              
                i;
                objFooterItem.Cells[i].ColumnSpan
              
              
                =
              
              
              
              
                this
              
              
                .Columns.Count
              
              
                -
              
              
                i;
                 if
              
              
                (
              
              
                this
              
              
                .bDefaultStyle)
              
              
                if
              
              
                (
              
              
                this
              
              
                .bDefaultStyle)
                 {
                
              
              
              
                
                  {
                   objFooterItem.Cells[i].Attributes[
                
                
                  "
                
                
                  class
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  "
                
                
                  t1
                
                
                  "
                
                
                  ;
                  objFooterItem.Cells[i].Attributes[
                
                
                  "
                
                
                  class
                
                
                  "
                
                
                  ]
                
                
                  =
                
                
                
                
                  "
                
                
                  t1
                
                
                  "
                
                
                  ;
                   }
                  }
                
              
              
                 if
              
              
                (
              
              
                this
              
              
                .Items.Count
              
              
                ==
              
              
                0
              
              
              
              
                &&
              
              
              
              
                this
              
              
                .ShowNoRecordMsg)
              
              
                //
              
              
                没有记录
              
              
                if
              
              
                (
              
              
                this
              
              
                .Items.Count
              
              
                ==
              
              
                0
              
              
              
              
                &&
              
              
              
              
                this
              
              
                .ShowNoRecordMsg)
              
              
                //
              
              
                没有记录
              
              
                 {
                
              
              
              
              
              
                
                  {
                   this
                
                
                  .objFooterItem.Cells[i].Text
                
                
                  =
                
                
                  @"
                
                
                  <tablewidth='100%'cellspacing='0'cellpadding='0'><TR><TDheight='20px'style='color:gray'align='center'>信息:没有查询到任何记录!</td></tr>
                
                
                  this
                
                
                  .objFooterItem.Cells[i].Text
                
                
                  =
                
                
                  @"
                
                
                  <tablewidth='100%'cellspacing='0'cellpadding='0'><TR><TDheight='20px'style='color:gray'align='center'>信息:没有查询到任何记录!</td></tr>
                   </table>
                
                
                  "
                
                
                  ;
                  </table>
                
                
                  "
                
                
                  ;
                   }
                  }
                
              
              
                 else
              
              
                else
              
              
                 {
                
              
              
              
                
                  {
                   this
                
                
                  .objFooterItem.Cells[i].HorizontalAlign
                
                
                  =
                
                
                  HorizontalAlign.Right;
                
                
                  this
                
                
                  .objFooterItem.Cells[i].HorizontalAlign
                
                
                  =
                
                
                  HorizontalAlign.Right;
                   this
                
                
                  .objFooterItem.Cells[i].Text
                
                
                  =
                
                
                
                
                  this
                
                
                  .GetPagerText();
                
                
                  this
                
                
                  .objFooterItem.Cells[i].Text
                
                
                  =
                
                
                
                
                  this
                
                
                  .GetPagerText();
                   this
                
                
                  .objFooterItem.Cells[i].Height
                
                
                  =
                
                
                
                
                  22
                
                
                  ;
                
                
                  this
                
                
                  .objFooterItem.Cells[i].Height
                
                
                  =
                
                
                
                
                  22
                
                
                  ;
                   //
                
                
                  e.Item.Cells[0].Style.Add("border-top","solid2px#336699");
                
                
                  //
                
                
                  e.Item.Cells[0].Style.Add("border-top","solid2px#336699");
                
                
                   }
                
                
                  }
                
              
              
                 }
                }
              
            
            
               
               
               
               
               if
            
            
              (
            
            
              this
            
            
              .HeaderStyle.CssClass
            
            
              ==
            
            
            
            
              ""
            
            
              )
            
            
              if
            
            
              (
            
            
              this
            
            
              .HeaderStyle.CssClass
            
            
              ==
            
            
            
            
              ""
            
            
              )
               {
              
            
            
            
              
                {
                 this
              
              
                .HeaderStyle.CssClass
              
              
                =
              
              
              
              
                "
              
              
                gridheader
              
              
                "
              
              
                ;
              
              
                this
              
              
                .HeaderStyle.CssClass
              
              
                =
              
              
              
              
                "
              
              
                gridheader
              
              
                "
              
              
                ;
                 }
                }
              
            
            
               if
            
            
              (
            
            
              this
            
            
              .ItemStyle.CssClass
            
            
              ==
            
            
              ""
            
            
              )
            
            
              if
            
            
              (
            
            
              this
            
            
              .ItemStyle.CssClass
            
            
              ==
            
            
              ""
            
            
              )
               {
              
            
            
            
              
                {
                 this
              
              
                .ItemStyle.CssClass
              
              
                =
              
              
                "
              
              
                t1
              
              
                "
              
              
                ;
              
              
                this
              
              
                .ItemStyle.CssClass
              
              
                =
              
              
                "
              
              
                t1
              
              
                "
              
              
                ;
                 }
                }
              
            
            
               if
            
            
              (
            
            
              this
            
            
              .AlternatingItemStyle.CssClass
            
            
              ==
            
            
              ""
            
            
              )
            
            
              if
            
            
              (
            
            
              this
            
            
              .AlternatingItemStyle.CssClass
            
            
              ==
            
            
              ""
            
            
              )
               {
              
            
            
            
              
                {
                 this
              
              
                .AlternatingItemStyle.CssClass
              
              
                =
              
              
                "
              
              
                t2
              
              
                "
              
              
                ;
              
              
                this
              
              
                .AlternatingItemStyle.CssClass
              
              
                =
              
              
                "
              
              
                t2
              
              
                "
              
              
                ;
                 }
                }
              
            
            
               
               this
            
            
              .ShowFooter
            
            
              =
            
            
            
            
              true
            
            
              ;
            
            
              this
            
            
              .ShowFooter
            
            
              =
            
            
            
            
              true
            
            
              ;
               base
            
            
              .OnPreRender(e);
            
            
              base
            
            
              .OnPreRender(e);
               }
              }
            
          
          
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             [Bindable(
          
          
            true
          
          
            ),
            [Bindable(
          
          
            true
          
          
            ),
             Category(
          
          
            "
          
          
            Appearance
          
          
            "
          
          
            ),
            Category(
          
          
            "
          
          
            Appearance
          
          
            "
          
          
            ),
             DefaultValue(
          
          
            ""
          
          
            )]
            DefaultValue(
          
          
            ""
          
          
            )]
             ///
            
            
            
            
              <summary>
            
          
          
          
            
              ///
            
            
            
            
              <summary>
            
            
               ///
            
            
              将此控件呈现给指定的输出参数。
            
            
              ///
            
            
              将此控件呈现给指定的输出参数。
               ///
            
            
            
            
              </summary>
            
            
              ///
            
            
            
            
              </summary>
            
            
               ///
            
            
            
            
              <paramname="output">
            
            
              要写出到的HTML编写器
            
            
              </param>
            
            
              ///
            
            
            
            
              <paramname="output">
            
            
              要写出到的HTML编写器
            
            
              </param>
            
            
            
          
           
          
             protected
          
          
          
          
            override
          
          
          
          
            void
          
          
            Render(HtmlTextWriteroutput)
          
          
            protected
          
          
          
          
            override
          
          
          
          
            void
          
          
            Render(HtmlTextWriteroutput)
             {
            
          
          
          
            
              {
               
               if
            
            
              (
            
            
              this
            
            
              .Context
            
            
              ==
            
            
            
            
              null
            
            
              )
            
            
              //
            
            
              设计
            
            
              if
            
            
              (
            
            
              this
            
            
              .Context
            
            
              ==
            
            
            
            
              null
            
            
              )
            
            
              //
            
            
              设计
            
            
               {
              
            
            
            
            
            
              
                {
                 output.Write(
              
              
                "
              
              
                <divstyle='width:100%;border:solid1px#336699'>
              
              
                "
              
              
                );
                output.Write(
              
              
                "
              
              
                <divstyle='width:100%;border:solid1px#336699'>
              
              
                "
              
              
                );
                 
                 output.Write(
              
              
                "
              
              
                <fontcolor='orange'>请注意:<BR>1、必须指定的参数:ConnectString,strSQL<BR>2、如果查询中只有一张表且有IdentityKey必须指定该Key</font>
              
              
                "
              
              
                );
                output.Write(
              
              
                "
              
              
                <fontcolor='orange'>请注意:<BR>1、必须指定的参数:ConnectString,strSQL<BR>2、如果查询中只有一张表且有IdentityKey必须指定该Key</font>
              
              
                "
              
              
                );
                 }
                }
              
            
            
               base
            
            
              .Render(output);
            
            
              base
            
            
              .Render(output);
               
               if
            
            
              (
            
            
              this
            
            
              .Context
            
            
              ==
            
            
            
            
              null
            
            
              )
            
            
              if
            
            
              (
            
            
              this
            
            
              .Context
            
            
              ==
            
            
            
            
              null
            
            
              )
               {
              
            
            
            
              
                {
                 output.Write(
              
              
                this
              
              
                .GetPagerText());
                output.Write(
              
              
                this
              
              
                .GetPagerText());
                 output.Write(
              
              
                "
              
              
                <DIV>
              
              
                "
              
              
                );
                output.Write(
              
              
                "
              
              
                <DIV>
              
              
                "
              
              
                );
                 }
                }
              
            
            
               
               
               }
              }
            
          
          
             
             ///
            
            
            
            
              <summary>
            
          
          
          
            
              ///
            
            
            
            
              <summary>
            
            
               ///
            
            
              利用存储过程进行分页
            
            
              ///
            
            
              利用存储过程进行分页
               ///
            
            
            
            
              </summary>
            
            
              ///
            
            
            
            
              </summary>
            
            
               ///
            
            
            
            
              <paramname="strSQl">
            
            
              sql
            
            
              </param>
            
            
              ///
            
            
            
            
              <paramname="strSQl">
            
            
              sql
            
            
              </param>
            
            
               ///
            
            
            
            
              <paramname="PrimaryKey">
            
            
              关键字段,一般为表的主健
            
            
              </param>
            
            
              ///
            
            
            
            
              <paramname="PrimaryKey">
            
            
              关键字段,一般为表的主健
            
            
              </param>
            
            
               ///
            
            
            
            
              <paramname="PageNo">
            
            
              当前页从1开始
            
            
              </param>
            
            
              ///
            
            
            
            
              <paramname="PageNo">
            
            
              当前页从1开始
            
            
              </param>
            
            
               ///
            
            
            
            
              <paramname="PageSize">
            
            
              页面大小
            
            
              </param>
            
            
              ///
            
            
            
            
              <paramname="PageSize">
            
            
              页面大小
            
            
              </param>
            
            
               ///
            
            
            
            
              <paramname="SortExpression">
            
            
              排序表达式
            
            
              </param>
            
            
              ///
            
            
            
            
              <paramname="SortExpression">
            
            
              排序表达式
            
            
              </param>
            
            
               ///
            
            
            
            
              <paramname="RecordCount">
            
            
              记录总数
            
            
              </param>
            
            
              ///
            
            
            
            
              <paramname="RecordCount">
            
            
              记录总数
            
            
              </param>
            
            
               ///
            
            
            
            
              <returns></returns>
            
            
              ///
            
            
            
            
              <returns></returns>
            
            
            
          
           public
          
          
            DataSetGetSqlResult(
          
          
            string
          
          
            strSQL,
          
          
            string
          
          
            PrimaryKey,
          
          
            int
          
          
            PageNo,
          
          
            int
          
          
            PageSize,
          
          
            string
          
          
            SortExpression,
          
          
            ref
          
          
          
          
            int
          
          
            RecordCount)
          
          
          
            public
          
          
            DataSetGetSqlResult(
          
          
            string
          
          
            strSQL,
          
          
            string
          
          
            PrimaryKey,
          
          
            int
          
          
            PageNo,
          
          
            int
          
          
            PageSize,
          
          
            string
          
          
            SortExpression,
          
          
            ref
          
          
          
          
            int
          
          
            RecordCount)
             {
            
          
          
          
            
              {
               SqlConnectionconn
            
            
              =
            
            
              null
            
            
              ;
              SqlConnectionconn
            
            
              =
            
            
              null
            
            
              ;
               SqlCommandcmd
            
            
              =
            
            
              null
            
            
              ;
              SqlCommandcmd
            
            
              =
            
            
              null
            
            
              ;
               SqlDataAdapterdapt
            
            
              =
            
            
              null
            
            
              ;
              SqlDataAdapterdapt
            
            
              =
            
            
              null
            
            
              ;
               try
            
            
              try
            
            
               {
              
            
            
            
              
                {
                 conn
              
              
                =
              
              
              
              
                new
              
              
                SqlConnection(
              
              
                this
              
              
                .ConnectionString);
                conn
              
              
                =
              
              
              
              
                new
              
              
                SqlConnection(
              
              
                this
              
              
                .ConnectionString);
                 
                 cmd
              
              
                =
              
              
              
              
                new
              
              
                SqlCommand(
              
              
                "
              
              
                GetPageResult
              
              
                "
              
              
                ,conn);
                cmd
              
              
                =
              
              
              
              
                new
              
              
                SqlCommand(
              
              
                "
              
              
                GetPageResult
              
              
                "
              
              
                ,conn);
                 cmd.CommandTimeout
              
              
                =
              
              
              
              
                60000
              
              
                ;
                cmd.CommandTimeout
              
              
                =
              
              
              
              
                60000
              
              
                ;
                 cmd.CommandType
              
              
                =
              
              
                CommandType.StoredProcedure;
                cmd.CommandType
              
              
                =
              
              
                CommandType.StoredProcedure;
                 SqlParameterpSql
              
              
                =
              
              
                cmd.Parameters.Add(
              
              
                "
              
              
                @sql
              
              
                "
              
              
                ,SqlDbType.NVarChar,
              
              
                4000
              
              
                );
                SqlParameterpSql
              
              
                =
              
              
                cmd.Parameters.Add(
              
              
                "
              
              
                @sql
              
              
                "
              
              
                ,SqlDbType.NVarChar,
              
              
                4000
              
              
                );
                 pSql.Value
              
              
                =
              
              
                strSQL;
                pSql.Value
              
              
                =
              
              
                strSQL;
                 SqlParameterpPKey
              
              
                =
              
              
                cmd.Parameters.Add(
              
              
                "
              
              
                @PKey
              
              
                "
              
              
                ,SqlDbType.VarChar,
              
              
                50
              
              
                );
                SqlParameterpPKey
              
              
                =
              
              
                cmd.Parameters.Add(
              
              
                "
              
              
                @PKey
              
              
                "
              
              
                ,SqlDbType.VarChar,
              
              
                50
              
              
                );
                 pPKey.Value
              
              
                =
              
              
                PrimaryKey;
                pPKey.Value
              
              
                =
              
              
                PrimaryKey;
                 SqlParameterpPageNo
              
              
                =
              
              
                cmd.Parameters.Add(
              
              
                "
              
              
                @PageNo
              
              
                "
              
              
                ,SqlDbType.Int,
              
              
                4
              
              
                );
                SqlParameterpPageNo
              
              
                =
              
              
                cmd.Parameters.Add(
              
              
                "
              
              
                @PageNo
              
              
                "
              
              
                ,SqlDbType.Int,
              
              
                4
              
              
                );
                 pPageNo.Value
              
              
                =
              
              
                PageNo;
                pPageNo.Value
              
              
                =
              
              
                PageNo;
                 SqlParameterpPageSize
              
              
                =
              
              
                cmd.Parameters.Add(
              
              
                "
              
              
                @PageSize
              
              
                "
              
              
                ,SqlDbType.Int,
              
              
                4
              
              
                );
                SqlParameterpPageSize
              
              
                =
              
              
                cmd.Parameters.Add(
              
              
                "
              
              
                @PageSize
              
              
                "
              
              
                ,SqlDbType.Int,
              
              
                4
              
              
                );
                 pPageSize.Value
              
              
                =
              
              
                PageSize;
                pPageSize.Value
              
              
                =
              
              
                PageSize;
                 SqlParameterpSort
              
              
                =
              
              
                cmd.Parameters.Add(
              
              
                "
              
              
                @sort
              
              
                "
              
              
                ,SqlDbType.VarChar,
              
              
                50
              
              
                );
                SqlParameterpSort
              
              
                =
              
              
                cmd.Parameters.Add(
              
              
                "
              
              
                @sort
              
              
                "
              
              
                ,SqlDbType.VarChar,
              
              
                50
              
              
                );
                 pSort.Value
              
              
                =
              
              
                SortExpression;
                pSort.Value
              
              
                =
              
              
                SortExpression;
                 SqlParameterpRecordCount
              
              
                =
              
              
                cmd.Parameters.Add(
              
              
                "
              
              
                @RecordCount
              
              
                "
              
              
                ,SqlDbType.Int,
              
              
                4
              
              
                );
                SqlParameterpRecordCount
              
              
                =
              
              
                cmd.Parameters.Add(
              
              
                "
              
              
                @RecordCount
              
              
                "
              
              
                ,SqlDbType.Int,
              
              
                4
              
              
                );
                 //
              
              
                pRecordCount.Value=SortExpression;
              
              
                //
              
              
                pRecordCount.Value=SortExpression;
              
              
                 pRecordCount.Direction
              
              
                =
              
              
                ParameterDirection.Output;
              
              
                pRecordCount.Direction
              
              
                =
              
              
                ParameterDirection.Output;
                 dapt
              
              
                =
              
              
              
              
                new
              
              
                SqlDataAdapter(cmd);
                dapt
              
              
                =
              
              
              
              
                new
              
              
                SqlDataAdapter(cmd);
                 conn.Open();
                conn.Open();
                 DataSetds
              
              
                =
              
              
              
              
                new
              
              
                DataSet();
                DataSetds
              
              
                =
              
              
              
              
                new
              
              
                DataSet();
                 dapt.Fill(ds,
              
              
                "
              
              
                Table1
              
              
                "
              
              
                );
                dapt.Fill(ds,
              
              
                "
              
              
                Table1
              
              
                "
              
              
                );
                 RecordCount
              
              
                =
              
              
                (
              
              
                int
              
              
                )pRecordCount.Value;
                RecordCount
              
              
                =
              
              
                (
              
              
                int
              
              
                )pRecordCount.Value;
                 return
              
              
                ds;
              
              
                return
              
              
                ds;
                 
                 }
                }
              
            
            
               catch
            
            
              (Exceptione)
            
            
              catch
            
            
              (Exceptione)
               {
              
            
            
            
              
                {
                 throw
              
              
                (e);
              
              
                throw
              
              
                (e);
                 //
              
              
                returnnull;
              
              
                //
              
              
                returnnull;
              
              
                 }
              
              
                }
              
            
            
               finally
            
            
              finally
            
            
               {
              
            
            
            
              
                {
                 if
              
              
                (conn
              
              
                !=
              
              
                null
              
              
                )
              
              
                if
              
              
                (conn
              
              
                !=
              
              
                null
              
              
                )
                 conn.Dispose();
                conn.Dispose();
                 if
              
              
                (cmd
              
              
                !=
              
              
                null
              
              
                )
              
              
                if
              
              
                (cmd
              
              
                !=
              
              
                null
              
              
                )
                 cmd.Dispose();
                cmd.Dispose();
                 if
              
              
                (dapt
              
              
                !=
              
              
                null
              
              
                )
              
              
                if
              
              
                (dapt
              
              
                !=
              
              
                null
              
              
                )
                 dapt.Dispose();
                dapt.Dispose();
                 }
                }
              
            
            
               
               }
              }
            
          
          
             
             ///
            
            
            
            
              <summary>
            
          
          
          
            
              ///
            
            
            
            
              <summary>
            
            
               ///
            
            
              利用存储过程进行分页
            
            
              ///
            
            
              利用存储过程进行分页
               ///
            
            
            
            
              </summary>
            
            
              ///
            
            
            
            
              </summary>
            
            
               ///
            
            
            
            
              <paramname="strSQl">
            
            
              sql
            
            
              </param>
            
            
              ///
            
            
            
            
              <paramname="strSQl">
            
            
              sql
            
            
              </param>
            
            
               ///
            
            
            
            
              <paramname="PrimaryKey">
            
            
              关键字段,一般为表的主健
            
            
              </param>
            
            
              ///
            
            
            
            
              <paramname="PrimaryKey">
            
            
              关键字段,一般为表的主健
            
            
              </param>
            
            
               ///
            
            
            
            
              <paramname="PageNo">
            
            
              当前页从1开始
            
            
              </param>
            
            
              ///
            
            
            
            
              <paramname="PageNo">
            
            
              当前页从1开始
            
            
              </param>
            
            
               ///
            
            
            
            
              <paramname="PageSize">
            
            
              页面大小
            
            
              </param>
            
            
              ///
            
            
            
            
              <paramname="PageSize">
            
            
              页面大小
            
            
              </param>
            
            
               ///
            
            
            
            
              <paramname="SortExpression">
            
            
              排序表达式
            
            
              </param>
            
            
              ///
            
            
            
            
              <paramname="SortExpression">
            
            
              排序表达式
            
            
              </param>
            
            
               ///
            
            
            
            
              <paramname="RecordCount">
            
            
              记录总数
            
            
              </param>
            
            
              ///
            
            
            
            
              <paramname="RecordCount">
            
            
              记录总数
            
            
              </param>
            
            
               ///
            
            
            
            
              <returns></returns>
            
            
              ///
            
            
            
            
              <returns></returns>
            
            
            
          
           public
          
          
            DataSetGetAccessResult(
          
          
            string
          
          
            strSQL,
          
          
            string
          
          
            PrimaryKey,
          
          
            int
          
          
            PageNo,
          
          
            int
          
          
            PageSize,
          
          
            string
          
          
            SortExpression,
          
          
            ref
          
          
          
          
            int
          
          
            RecordCount)
          
          
          
            public
          
          
            DataSetGetAccessResult(
          
          
            string
          
          
            strSQL,
          
          
            string
          
          
            PrimaryKey,
          
          
            int
          
          
            PageNo,
          
          
            int
          
          
            PageSize,
          
          
            string
          
          
            SortExpression,
          
          
            ref
          
          
          
          
            int
          
          
            RecordCount)
             {
            
          
          
          
            
              {
               
               
               DataSetds
            
            
              =
            
            
            
            
              new
            
            
              DataSet();
              DataSetds
            
            
              =
            
            
            
            
              new
            
            
              DataSet();
               if
            
            
              (System.Web.HttpContext.Current.Session[
            
            
              this
            
            
              .Page.ToString()]
            
            
              ==
            
            
              null
            
            
              ||
            
            
              (
            
            
              !
            
            
              this
            
            
              .Page.IsPostBack))
            
            
              if
            
            
              (System.Web.HttpContext.Current.Session[
            
            
              this
            
            
              .Page.ToString()]
            
            
              ==
            
            
              null
            
            
              ||
            
            
              (
            
            
              !
            
            
              this
            
            
              .Page.IsPostBack))
               {
              
            
            
            
              
                {
                 
                 OleDbConnectionconn
              
              
                =
              
              
                null
              
              
                ;
                OleDbConnectionconn
              
              
                =
              
              
                null
              
              
                ;
                 OleDbDataAdapterdapt
              
              
                =
              
              
                null
              
              
                ;
                OleDbDataAdapterdapt
              
              
                =
              
              
                null
              
              
                ;
                 try
              
              
                try
              
              
                 {
                
              
              
              
                
                  {
                   
                   
                   conn
                
                
                  =
                
                
                
                
                  new
                
                
                  OleDbConnection(
                
                
                  this
                
                
                  .ConnectionString);
                  conn
                
                
                  =
                
                
                
                
                  new
                
                
                  OleDbConnection(
                
                
                  this
                
                
                  .ConnectionString);
                   conn.Open();
                  conn.Open();
                   dapt
                
                
                  =
                
                
                
                
                  new
                
                
                  OleDbDataAdapter(strSQL,conn);
                  dapt
                
                
                  =
                
                
                
                
                  new
                
                
                  OleDbDataAdapter(strSQL,conn);
                   //
                
                
                  DataSetds=newDataSet();
                
                
                  //
                
                
                  DataSetds=newDataSet();
                
                
                   dapt.Fill(ds,
                
                
                  "
                
                
                  Table1
                
                
                  "
                
                
                  );
                
                
                  dapt.Fill(ds,
                
                
                  "
                
                
                  Table1
                
                
                  "
                
                
                  );
                   System.Web.HttpContext.Current.Session[
                
                
                  this
                
                
                  .Page.ToString()]
                
                
                  =
                
                
                  ds;
                  System.Web.HttpContext.Current.Session[
                
                
                  this
                
                
                  .Page.ToString()]
                
                
                  =
                
                
                  ds;
                   }
                  }
                
              
              
                 catch
              
              
                (Exceptione)
              
              
                catch
              
              
                (Exceptione)
                 {
                
              
              
              
                
                  {
                   throw
                
                
                  (e);
                
                
                  throw
                
                
                  (e);
                   //
                
                
                  returnnull;
                
                
                  //
                
                
                  returnnull;
                
                
                   }
                
                
                  }
                
              
              
                 finally
              
              
                finally
              
              
                 {
                
              
              
              
                
                  {
                   if
                
                
                  (conn
                
                
                  !=
                
                
                  null
                
                
                  )
                
                
                  if
                
                
                  (conn
                
                
                  !=
                
                
                  null
                
                
                  )
                   conn.Dispose();
                  conn.Dispose();
                   
                   if
                
                
                  (dapt
                
                
                  !=
                
                
                  null
                
                
                  )
                
                
                  if
                
                
                  (dapt
                
                
                  !=
                
                
                  null
                
                
                  )
                   dapt.Dispose();
                  dapt.Dispose();
                   }
                  }
                
              
              
                 }
                }
              
            
            
               else
            
            
              else
            
            
               {
              
            
            
            
              
                {
                 ds
              
              
                =
              
              
                (DataSet)System.Web.HttpContext.Current.Session[
              
              
                this
              
              
                .Page.ToString()];
                ds
              
              
                =
              
              
                (DataSet)System.Web.HttpContext.Current.Session[
              
              
                this
              
              
                .Page.ToString()];
                 }
                }
              
            
            
               
               DataViewdv
            
            
              =
            
            
              ds.Tables[
            
            
              0
            
            
              ].DefaultView;
              DataViewdv
            
            
              =
            
            
              ds.Tables[
            
            
              0
            
            
              ].DefaultView;
               if
            
            
              (SortExpression
            
            
              !=
            
            
              ""
            
            
              )
            
            
              if
            
            
              (SortExpression
            
            
              !=
            
            
              ""
            
            
              )
               dv.Sort
            
            
              =
            
            
              SortExpression;
              dv.Sort
            
            
              =
            
            
              SortExpression;
               RecordCount
            
            
              =
            
            
              dv.Count;
              RecordCount
            
            
              =
            
            
              dv.Count;
               
               DataTabledt
            
            
              =
            
            
              ds.Tables[
            
            
              0
            
            
              ].Clone();
              DataTabledt
            
            
              =
            
            
              ds.Tables[
            
            
              0
            
            
              ].Clone();
               int
            
            
              iStart
            
            
              =
            
            
              (PageNo
            
            
              -
            
            
              1
            
            
              )
            
            
              *
            
            
              PageSize
            
            
              +
            
            
              1
            
            
              ;
            
            
              int
            
            
              iStart
            
            
              =
            
            
              (PageNo
            
            
              -
            
            
              1
            
            
              )
            
            
              *
            
            
              PageSize
            
            
              +
            
            
              1
            
            
              ;
               int
            
            
              iEnd
            
            
              =
            
            
              PageNo
            
            
              *
            
            
              PageSize;
            
            
              int
            
            
              iEnd
            
            
              =
            
            
              PageNo
            
            
              *
            
            
              PageSize;
               //
            
            
              System.Web.HttpContext.Current.Response.Write(this.PageCount1);
            
            
              //
            
            
              System.Web.HttpContext.Current.Response.Write(this.PageCount1);
            
            
               
            
            
               if
            
            
              (iEnd
            
            
              >
            
            
              dv.Count)
            
            
              if
            
            
              (iEnd
            
            
              >
            
            
              dv.Count)
               iEnd
            
            
              =
            
            
              dv.Count;
              iEnd
            
            
              =
            
            
              dv.Count;
               
               if
            
            
              (iStart
            
            
              >
            
            
              0
            
            
            
            
              &&
            
            
              iEnd
            
            
              >=
            
            
              iStart)
            
            
              if
            
            
              (iStart
            
            
              >
            
            
              0
            
            
            
            
              &&
            
            
              iEnd
            
            
              >=
            
            
              iStart)
               {
              
            
            
            
              
                {
                 for
              
              
                (
              
              
                int
              
              
                i
              
              
                =
              
              
                iStart
              
              
                -
              
              
                1
              
              
                ;i
              
              
                <
              
              
                iEnd;i
              
              
                ++
              
              
                )
              
              
                for
              
              
                (
              
              
                int
              
              
                i
              
              
                =
              
              
                iStart
              
              
                -
              
              
                1
              
              
                ;i
              
              
                <
              
              
                iEnd;i
              
              
                ++
              
              
                )
                 {
                
              
              
              
                
                  {
                   DataRowrow
                
                
                  =
                
                
                  dt.NewRow();
                  DataRowrow
                
                
                  =
                
                
                  dt.NewRow();
                   row.ItemArray
                
                
                  =
                
                
                  dv[i].Row.ItemArray;
                  row.ItemArray
                
                
                  =
                
                
                  dv[i].Row.ItemArray;
                   
                   dt.Rows.Add(row);
                  dt.Rows.Add(row);
                   }
                  }
                
              
              
                 }
                }
              
            
            
               //
            
            
              ds=null;
            
            
              //
            
            
              ds=null;
            
            
               dv
            
            
              =
            
            
            
            
              null
            
            
              ;
            
            
              dv
            
            
              =
            
            
            
            
              null
            
            
              ;
               ds
            
            
              =
            
            
            
            
              new
            
            
              DataSet();
              ds
            
            
              =
            
            
            
            
              new
            
            
              DataSet();
               ds.Tables.Add(dt);
              ds.Tables.Add(dt);
               return
            
            
              ds;
            
            
              return
            
            
              ds;
               
               }
              }
            
          
          
             
             
             private
          
          
          
          
            string
          
          
            GetRequestValue(
          
          
            string
          
          
            sKey)
          
          
            private
          
          
          
          
            string
          
          
            GetRequestValue(
          
          
            string
          
          
            sKey)
             {
            
          
          
          
            
              {
               object
            
            
              o
            
            
              =
            
            
            
            
              this
            
            
              .Page.Request.Form[sKey];
            
            
              object
            
            
              o
            
            
              =
            
            
            
            
              this
            
            
              .Page.Request.Form[sKey];
               if
            
            
              (o
            
            
              !=
            
            
              null
            
            
              )
            
            
              if
            
            
              (o
            
            
              !=
            
            
              null
            
            
              )
               {
              
            
            
            
              
                {
                 return
              
              
                o.ToString().Trim();
              
              
                return
              
              
                o.ToString().Trim();
                 }
                }
              
            
            
               return
            
            
            
            
              ""
            
            
              ;
            
            
              return
            
            
            
            
              ""
            
            
              ;
               }
              }
            
          
          
             
             
             
             public
          
          
          
          
            override
          
          
          
          
            void
          
          
            DataBind()
          
          
            public
          
          
          
          
            override
          
          
          
          
            void
          
          
            DataBind()
             {
            
          
          
          
            
              {
               if
            
            
              (
            
            
              this
            
            
              .Context
            
            
              ==
            
            
            
            
              null
            
            
              )
            
            
              if
            
            
              (
            
            
              this
            
            
              .Context
            
            
              ==
            
            
            
            
              null
            
            
              )
               {
              
            
            
            
              
                {
                 base
              
              
                .DataBind();
              
              
                base
              
              
                .DataBind();
                 return
              
              
                ;
              
              
                return
              
              
                ;
                 }
                }
              
            
            
               if
            
            
              (
            
            
              this
            
            
              .ConnectionString
            
            
              ==
            
            
              ""
            
            
              )
            
            
              if
            
            
              (
            
            
              this
            
            
              .ConnectionString
            
            
              ==
            
            
              ""
            
            
              )
               {
              
            
            
            
              
                {
                 throw
              
              
                (
              
              
                new
              
              
                Exception(
              
              
                "
              
              
                没有指定ConnectionString
              
              
                "
              
              
                ));
              
              
                throw
              
              
                (
              
              
                new
              
              
                Exception(
              
              
                "
              
              
                没有指定ConnectionString
              
              
                "
              
              
                ));
                 }
                }
              
            
            
               if
            
            
              (
            
            
              this
            
            
              .strSQL
            
            
              ==
            
            
              ""
            
            
              )
            
            
              if
            
            
              (
            
            
              this
            
            
              .strSQL
            
            
              ==
            
            
              ""
            
            
              )
               {
              
            
            
            
              
                {
                 throw
              
              
                (
              
              
                new
              
              
                Exception(
              
              
                "
              
              
                没有指定strSQL
              
              
                "
              
              
                ));
              
              
                throw
              
              
                (
              
              
                new
              
              
                Exception(
              
              
                "
              
              
                没有指定strSQL
              
              
                "
              
              
                ));
                 }
                }
              
            
            
               
               int
            
            
              iCount
            
            
              =
            
            
              0
            
            
              ;
            
            
              int
            
            
              iCount
            
            
              =
            
            
              0
            
            
              ;
               //
            
            
              AddBYzhaofeng2004-11-19
            
            
              //
            
            
              AddBYzhaofeng2004-11-19
            
            
               if
            
            
              (
            
            
              this
            
            
              .CurrentPageNo
            
            
              >
            
            
              this
            
            
              .PageCount1)
            
            
            
            
              if
            
            
              (
            
            
              this
            
            
              .CurrentPageNo
            
            
              >
            
            
              this
            
            
              .PageCount1)
               {
              
            
            
            
              
                {
                 this
              
              
                .CurrentPageNo
              
              
                =
              
              
              
              
                this
              
              
                .PageCount1;
              
              
                this
              
              
                .CurrentPageNo
              
              
                =
              
              
              
              
                this
              
              
                .PageCount1;
                 }
                }
              
            
            
               if
            
            
              (
            
            
              this
            
            
              .CurrentPageNo
            
            
              ==
            
            
            
            
              0
            
            
              )
            
            
              if
            
            
              (
            
            
              this
            
            
              .CurrentPageNo
            
            
              ==
            
            
            
            
              0
            
            
              )
               this
            
            
              .CurrentPageNo
            
            
              =
            
            
            
            
              1
            
            
              ;
            
            
              this
            
            
              .CurrentPageNo
            
            
              =
            
            
            
            
              1
            
            
              ;
               //
            
            
              AddEnd
            
            
              //
            
            
              AddEnd
            
            
               DataSetds
            
            
              =
            
            
            
            
              null
            
            
              ;
            
            
              DataSetds
            
            
              =
            
            
            
            
              null
            
            
              ;
               if
            
            
              (
            
            
              this
            
            
              .bIsAccess)
            
            
              if
            
            
              (
            
            
              this
            
            
              .bIsAccess)
               ds
            
            
              =
            
            
            
            
              this
            
            
              .GetAccessResult(
            
            
              this
            
            
              .strSQL,
            
            
              this
            
            
              .IdentityKey,
            
            
              this
            
            
              .CurrentPageNo,
            
            
              this
            
            
              .PageSize,
            
            
              this
            
            
              .SortExpression,
            
            
              ref
            
            
              iCount);
              ds
            
            
              =
            
            
            
            
              this
            
            
              .GetAccessResult(
            
            
              this
            
            
              .strSQL,
            
            
              this
            
            
              .IdentityKey,
            
            
              this
            
            
              .CurrentPageNo,
            
            
              this
            
            
              .PageSize,
            
            
              this
            
            
              .SortExpression,
            
            
              ref
            
            
              iCount);
               else
            
            
              else
            
            
               
               ds
            
            
              =
            
            
            
            
              this
            
            
              .GetSqlResult(
            
            
              this
            
            
              .strSQL,
            
            
              this
            
            
              .IdentityKey,
            
            
              this
            
            
              .CurrentPageNo,
            
            
              this
            
            
              .PageSize,
            
            
              this
            
            
              .SortExpression,
            
            
              ref
            
            
              iCount);
              ds
            
            
              =
            
            
            
            
              this
            
            
              .GetSqlResult(
            
            
              this
            
            
              .strSQL,
            
            
              this
            
            
              .IdentityKey,
            
            
              this
            
            
              .CurrentPageNo,
            
            
              this
            
            
              .PageSize,
            
            
              this
            
            
              .SortExpression,
            
            
              ref
            
            
              iCount);
               
               this
            
            
              .RecordCount
            
            
              =
            
            
              iCount;
            
            
              this
            
            
              .RecordCount
            
            
              =
            
            
              iCount;
               this
            
            
              .DataSource
            
            
              =
            
            
              ds.Tables[
            
            
              0
            
            
              ].DefaultView;
            
            
              this
            
            
              .DataSource
            
            
              =
            
            
              ds.Tables[
            
            
              0
            
            
              ].DefaultView;
               base
            
            
              .DataBind();
            
            
              base
            
            
              .DataBind();
               }
              }
            
          
          
             
             private
          
          
          
          
            void
          
          
            DoPager()
          
          
            private
          
          
          
          
            void
          
          
            DoPager()
             {
            
          
          
          
            
              {
               string
            
            
              sAcionType
            
            
              =
            
            
            
            
              this
            
            
              .GetRequestValue(
            
            
              "
            
            
              hidAction_
            
            
              "
            
            
              +
            
            
              this
            
            
              .ID);
            
            
              string
            
            
              sAcionType
            
            
              =
            
            
            
            
              this
            
            
              .GetRequestValue(
            
            
              "
            
            
              hidAction_
            
            
              "
            
            
              +
            
            
              this
            
            
              .ID);
               switch
            
            
              (sAcionType)
            
            
              switch
            
            
              (sAcionType)
               {
              
            
            
            
              
                {
                 case
              
              
              
              
                "
              
              
                1
              
              
                "
              
              
                :
              
              
                case
              
              
              
              
                "
              
              
                1
              
              
                "
              
              
                :
                 this
              
              
                .CurrentPageNo
              
              
                =
              
              
                1
              
              
                ;
              
              
                this
              
              
                .CurrentPageNo
              
              
                =
              
              
                1
              
              
                ;
                 break
              
              
                ;
              
              
                break
              
              
                ;
                 case
              
              
              
              
                "
              
              
                2
              
              
                "
              
              
                :
              
              
                case
              
              
              
              
                "
              
              
                2
              
              
                "
              
              
                :
                 if
              
              
                (
              
              
                this
              
              
                .CurrentPageNo
              
              
                >
              
              
                1
              
              
                )
              
              
                if
              
              
                (
              
              
                this
              
              
                .CurrentPageNo
              
              
                >
              
              
                1
              
              
                )
                 {
                
              
              
              
                
                  {
                   this
                
                
                  .CurrentPageNo
                
                
                  =
                
                
                
                
                  this
                
                
                  .CurrentPageNo
                
                
                  -
                
                
                  1
                
                
                  ;
                
                
                  this
                
                
                  .CurrentPageNo
                
                
                  =
                
                
                
                
                  this
                
                
                  .CurrentPageNo
                
                
                  -
                
                
                  1
                
                
                  ;
                   }
                  }
                
              
              
                 else
              
              
                else
              
              
                 return
              
              
                ;
              
              
                return
              
              
                ;
                 break
              
              
                ;
              
              
                break
              
              
                ;
                 case
              
              
              
              
                "
              
              
                3
              
              
                "
              
              
                :
              
              
                case
              
              
              
              
                "
              
              
                3
              
              
                "
              
              
                :
                 
                 if
              
              
                (
              
              
                this
              
              
                .CurrentPageNo
              
              
                <
              
              
                this
              
              
                .PageCount1)
              
              
                if
              
              
                (
              
              
                this
              
              
                .CurrentPageNo
              
              
                <
              
              
                this
              
              
                .PageCount1)
                 {
                
              
              
              
                
                  {
                   this
                
                
                  .CurrentPageNo
                
                
                  =
                
                
                
                
                  this
                
                
                  .CurrentPageNo
                
                
                  +
                
                
                  1
                
                
                  ;
                
                
                  this
                
                
                  .CurrentPageNo
                
                
                  =
                
                
                
                
                  this
                
                
                  .CurrentPageNo
                
                
                  +
                
                
                  1
                
                
                  ;
                   }
                  }
                
              
              
                 else
              
              
                else
              
              
                 return
              
              
                ;
              
              
                return
              
              
                ;
                 break
              
              
                ;
              
              
                break
              
              
                ;
                 case
              
              
              
              
                "
              
              
                4
              
              
                "
              
              
                :
              
              
                case
              
              
              
              
                "
              
              
                4
              
              
                "
              
              
                :
                 if
              
              
                (
              
              
                this
              
              
                .CurrentPageNo
              
              
                !=
              
              
                this
              
              
                .PageCount1)
              
              
                if
              
              
                (
              
              
                this
              
              
                .CurrentPageNo
              
              
                !=
              
              
                this
              
              
                .PageCount1)
                 {
                
              
              
              
                
                  {
                   this
                
                
                  .CurrentPageNo
                
                
                  =
                
                
                
                
                  this
                
                
                  .PageCount1;
                
                
                  this
                
                
                  .CurrentPageNo
                
                
                  =
                
                
                
                
                  this
                
                
                  .PageCount1;
                   }
                  }
                
              
              
                 else
              
              
                else
              
              
                 return
              
              
                ;
              
              
                return
              
              
                ;
                 break
              
              
                ;
              
              
                break
              
              
                ;
                 case
              
              
              
              
                "
              
              
                5
              
              
                "
              
              
                :
              
              
                //
              
              
                Goto
              
              
                case
              
              
              
              
                "
              
              
                5
              
              
                "
              
              
                :
              
              
                //
              
              
                Goto
              
              
                 string
              
              
                sCurPage
              
              
                =
              
              
              
              
                this
              
              
                .GetRequestValue(
              
              
                "
              
              
                txtGoPage_
              
              
                "
              
              
                +
              
              
                this
              
              
                .ID);
              
              
              
              
                string
              
              
                sCurPage
              
              
                =
              
              
              
              
                this
              
              
                .GetRequestValue(
              
              
                "
              
              
                txtGoPage_
              
              
                "
              
              
                +
              
              
                this
              
              
                .ID);
                 if
              
              
                (CCConvert.IsInt32(sCurPage))
              
              
                if
              
              
                (CCConvert.IsInt32(sCurPage))
                 {
                
              
              
              
                
                  {
                   int
                
                
                  iCurrentPageNo
                
                
                  =
                
                
                  Convert.ToInt32(sCurPage);
                
                
                  int
                
                
                  iCurrentPageNo
                
                
                  =
                
                
                  Convert.ToInt32(sCurPage);
                   if
                
                
                  (iCurrentPageNo
                
                
                  >
                
                
                  0
                
                
                
                
                  &&
                
                
                  iCurrentPageNo
                
                
                  <=
                
                
                  this
                
                
                  .PageCount1)
                
                
                  if
                
                
                  (iCurrentPageNo
                
                
                  >
                
                
                  0
                
                
                
                
                  &&
                
                
                  iCurrentPageNo
                
                
                  <=
                
                
                  this
                
                
                  .PageCount1)
                   {
                  
                
                
                
                  
                    {
                     this
                  
                  
                    .CurrentPageNo
                  
                  
                    =
                  
                  
                    iCurrentPageNo;
                  
                  
                    this
                  
                  
                    .CurrentPageNo
                  
                  
                    =
                  
                  
                    iCurrentPageNo;
                     }
                    }
                  
                
                
                   }
                  }
                
              
              
                 else
              
              
                else
              
              
                 return
              
              
                ;
              
              
                return
              
              
                ;
                 break
              
              
                ;
              
              
                break
              
              
                ;
                 case
              
              
              
              
                "
              
              
                6
              
              
                "
              
              
                :
              
              
                //
              
              
                重设显示页数
              
              
                case
              
              
              
              
                "
              
              
                6
              
              
                "
              
              
                :
              
              
                //
              
              
                重设显示页数
              
              
                 string
              
              
                sPageSize
              
              
                =
              
              
              
              
                this
              
              
                .GetRequestValue(
              
              
                "
              
              
                txtRowsPager_
              
              
                "
              
              
                +
              
              
                this
              
              
                .ID);
              
              
              
              
                string
              
              
                sPageSize
              
              
                =
              
              
              
              
                this
              
              
                .GetRequestValue(
              
              
                "
              
              
                txtRowsPager_
              
              
                "
              
              
                +
              
              
                this
              
              
                .ID);
                 if
              
              
                (CCConvert.IsInt32(sPageSize))
              
              
                if
              
              
                (CCConvert.IsInt32(sPageSize))
                 {
                
              
              
              
                
                  {
                   int
                
                
                  iPage
                
                
                  =
                
                
                  Convert.ToInt32(sPageSize);
                
                
                  int
                
                
                  iPage
                
                
                  =
                
                
                  Convert.ToInt32(sPageSize);
                   if
                
                
                  (iPage
                
                
                  >
                
                
                  0
                
                
                  )
                
                
                  if
                
                
                  (iPage
                
                
                  >
                
                
                  0
                
                
                  )
                   this
                
                
                  .PageSize
                
                
                  =
                
                
                  iPage;
                
                
                  this
                
                
                  .PageSize
                
                
                  =
                
                
                  iPage;
                   else
                
                
                  else
                
                
                   return
                
                
                  ;
                
                
                  return
                
                
                  ;
                   }
                  }
                
              
              
                 else
              
              
                else
              
              
                 return
              
              
                ;
              
              
                return
              
              
                ;
                 break
              
              
                ;
              
              
                break
              
              
                ;
                 default
              
              
                :
              
              
                default
              
              
                :
                 return
              
              
                ;
              
              
                return
              
              
                ;
                 
                 }
                }
              
            
            
               
               
               this
            
            
              .DataBind();
            
            
              this
            
            
              .DataBind();
               }
              }
            
          
          
             IPostBackEventHandler成员
            
          
          
            IPostBackEventHandler成员
          
          
          
             }
            }
          
        
        
           }
          }
        
      
      
         
      
    
用到的存储过程:
      
        SET
      
      
        QUOTED_IDENTIFIER
      
      
        OFF
      
      
        
GO
SET ANSI_NULLS OFF
GO
        
        
        
        
        
/* ****************************
名称:GetPageResult
功能:得到分页记录集
作者:cpp2017
编写时间:2002-08-17
**************************** */
        
CREATE PROCEDURE GetPageResult
@sql nvarchar ( 4000 ), -- SqlStatment
@PKey varchar ( 100 ), -- -PrimaryKeyName
@PageNo int , -- CurrentPageNo
@PageSize int , -- PageSize
@Sort varchar ( 50 ), -- SortField
@RecordCount int output -- RecordCount传出参数
AS
BEGIN
        
        
DECLARE @sqlStr NVARCHAR ( 4000 );
-- -得到记录总数Start
if @RecordCount = - 1 or @RecordCount is null
begin
SET @sqlStr = ' select@count=Count(1)from( ' + @sql + ' )asAA ' ;
EXECUTE sp_executesql @sqlStr ,N ' @countintout ' , @RecordCount out;
end
-- -得到记录总数End
-- 加上排序Start
IF @Sort IS not null and @sort <> ''
BEGIN
        
Set @sort = ' orderby ' + @sort ;
END
-- 加上排序End
IF ( @PageNo = 1 ) -- 第一页
SET @sqlStr = ' selecttop ' + cast ( @PageSize as varchar ( 5 )) + ' *FROM( ' + @sql + ' )ASAA ' + @sort
ELSE
        
BEGIN
declare @sMaxCount varchar ( 10 )
declare @sMinCount varchar ( 10 )
set @sMaxCount = cast ( @PageSize * @PageNo as varchar ( 5 ))
set @sMinCount = Convert ( nvarchar ( 10 ),( @PageNo - 1 ) * @PageSize )
        
        
if @PKey != '' or @PKey is null -- 如果有主键,注此key必须是identitykey
begin
SET @sqlStr = ' selecttop ' + @sMaxCount + ' ' + @PKey + ' into#tempfrom( ' + @sql + ' )asAA ' + @sort + ' ; '
Set @sqlStr = @sqlStr + ' deletefrom#tempwhere ' + @PKey + ' in(selecttop ' + @sMinCount + ' ' + @PKey + ' from#temp); '
SET @sqlStr = @sqlStr + ' selectA.*from( ' + @sql + ' )ASAINNERJOIN#tempasBONA. ' + @PKey + ' =B. ' + @Pkey + ' ;droptable#temp '
end
else
Begin
SET @sqlStr = ' selecttop ' + @sMaxCount + ' *into#tempfrom( ' + @sql + ' )asAA ' + @sort + ' ; '
SET @sqlStr = @sqlStr + ' exec( '' altertable#tempaddPrimaryKeyintidentity(1,1); '' );deletefrom#tempwherePrimaryKeyin(selecttop ' + @sMinCount + ' PrimaryKeyFrom#temp) '
        
SET @sqlStr = @sqlStr + ' ;select*from#temp;droptable#temp '
end
END
        
EXECUTE ( @sqlStr )
print @sqlstr
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
        
      
    
  GO
SET ANSI_NULLS OFF
GO
/* ****************************
名称:GetPageResult
功能:得到分页记录集
作者:cpp2017
编写时间:2002-08-17
**************************** */
CREATE PROCEDURE GetPageResult
@sql nvarchar ( 4000 ), -- SqlStatment
@PKey varchar ( 100 ), -- -PrimaryKeyName
@PageNo int , -- CurrentPageNo
@PageSize int , -- PageSize
@Sort varchar ( 50 ), -- SortField
@RecordCount int output -- RecordCount传出参数
AS
BEGIN
DECLARE @sqlStr NVARCHAR ( 4000 );
-- -得到记录总数Start
if @RecordCount = - 1 or @RecordCount is null
begin
SET @sqlStr = ' select@count=Count(1)from( ' + @sql + ' )asAA ' ;
EXECUTE sp_executesql @sqlStr ,N ' @countintout ' , @RecordCount out;
end
-- -得到记录总数End
-- 加上排序Start
IF @Sort IS not null and @sort <> ''
BEGIN
Set @sort = ' orderby ' + @sort ;
END
-- 加上排序End
IF ( @PageNo = 1 ) -- 第一页
SET @sqlStr = ' selecttop ' + cast ( @PageSize as varchar ( 5 )) + ' *FROM( ' + @sql + ' )ASAA ' + @sort
ELSE
BEGIN
declare @sMaxCount varchar ( 10 )
declare @sMinCount varchar ( 10 )
set @sMaxCount = cast ( @PageSize * @PageNo as varchar ( 5 ))
set @sMinCount = Convert ( nvarchar ( 10 ),( @PageNo - 1 ) * @PageSize )
if @PKey != '' or @PKey is null -- 如果有主键,注此key必须是identitykey
begin
SET @sqlStr = ' selecttop ' + @sMaxCount + ' ' + @PKey + ' into#tempfrom( ' + @sql + ' )asAA ' + @sort + ' ; '
Set @sqlStr = @sqlStr + ' deletefrom#tempwhere ' + @PKey + ' in(selecttop ' + @sMinCount + ' ' + @PKey + ' from#temp); '
SET @sqlStr = @sqlStr + ' selectA.*from( ' + @sql + ' )ASAINNERJOIN#tempasBONA. ' + @PKey + ' =B. ' + @Pkey + ' ;droptable#temp '
end
else
Begin
SET @sqlStr = ' selecttop ' + @sMaxCount + ' *into#tempfrom( ' + @sql + ' )asAA ' + @sort + ' ; '
SET @sqlStr = @sqlStr + ' exec( '' altertable#tempaddPrimaryKeyintidentity(1,1); '' );deletefrom#tempwherePrimaryKeyin(selecttop ' + @sMinCount + ' PrimaryKeyFrom#temp) '
SET @sqlStr = @sqlStr + ' ;select*from#temp;droptable#temp '
end
END
EXECUTE ( @sqlStr )
print @sqlstr
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1538109


 
       
					 
					