关于AspNetPager这里就不多说了,下面我就写一个最简单的应用。
private void Page_Load(object sender, System.EventArgs e)
        
{
            
if(!Page.IsPostBack)
            
{
                
int pageNum = db.ExecuteScalarSql("select count(pk_id) from 数据库表描述");
                
this.AspNetPager1.RecordCount = pageNum;
                GetPage();                
            }

        }


        
private void BindGrid()
        
{
            
string strsql = "select * from 数据库表描述";
            SqlDataAdapter adapter
= new SqlDataAdapter(strsql,new SqlConnection(ConfigurationSettings.AppSettings["strcon"])); 
            DataSet ds
=new DataSet(); 
            adapter.Fill(ds,AspNetPager1.PageSize
*(AspNetPager1.CurrentPageIndex-1),AspNetPager1.PageSize,"IU_User");   
            
this.DataGrid1.DataSource=ds.Tables["IU_User"]; 
            
this.DataGrid1.DataBind(); 
        }


        
private void GetPage()
        
{
            BindGrid();
            AspNetPager1.CustomInfoHTML 
= "当前页:  <font color=\"red\"><b>" + AspNetPager1.CurrentPageIndex + "</b></font> 总页数:  " + AspNetPager1.PageCount;
            AspNetPager1.CustomInfoHTML 
+= "&nbsp;&nbsp;在 " + AspNetPager1.StartRecordIndex + "-" + AspNetPager1.EndRecordIndex;
        }


        
private void AspNetPager1_PageChanged(object sender, System.EventArgs e)
        
{
            GetPage();
        }

 posted on 2007-11-06 10:24  思绪随风  阅读(554)  评论(0编辑  收藏  举报