在网上也看了一部分帖子,都说的不是很清楚,都是把代码往那一放,就不管了。我现在已经做到在vs2005里添加了aspnetpanger控件,可剩下的我就不会了。那假设我现在已经拖放进去一个datalist和aspnetpager控件,那我剩下的步骤该怎么办呢万分感谢大家的详细解答,万分感谢!!!

解决方案 »

  1.   

    没用过..
    学他要花时间.
       //第一页
        protected void btn_OnePage_Click(object sender, EventArgs e)
        {
           this.bind(this.State);
        }    //上一页
        protected void btn_LastPage_Click(object sender, EventArgs e)
        {
            Button button = sender as Button;
            this.bind(this.State, Int32.Parse(button.CommandArgument));
        }    //下一页
        protected void btn_NextPage_Click(object sender, EventArgs e)
        {
            Button button = sender as Button;
            this.bind(this.State, Int32.Parse(button.CommandArgument));
        }    //最后一页
        protected void btn_FinalPage_Click(object sender, EventArgs e)
        {
            Button button = sender as Button;
            this.bind(this.State, Int32.Parse(button.CommandArgument));
        }    //下拉选择页
        protected void ddl_Pages_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList ddl = sender as DropDownList;
            this.bind(this.State, ddl.SelectedIndex + 1);
        }
    bind()
    里就是数据操作等.
    button.CommandArgument是标式
      

  2.   

    绑定数据的时候注意一下设置分页就行了  public void BindData()
    {
    AspNetPager1.RecordCount= getRecordCount();

    DataGrid1.DataSource= date(); 
    DataGrid1.DataBind(); AspNetPager1.CustomInfoText="记录总数:<font color=\"blue\"><b>"+AspNetPager1.RecordCount.ToString()+"</b></font>";
    AspNetPager1.CustomInfoText+=" 总页数:<font color=\"blue\"><b>"+AspNetPager1.PageCount.ToString()+"</b></font>";
    AspNetPager1.CustomInfoText+=" 当前页:<font color=\"red\"><b>"+AspNetPager1.CurrentPageIndex.ToString()+"</b></font>";
    }
      

  3.   

    我还是建议不要用AspNetPager,有时没必要。ObjectDataSource的属性栏你看看,有EnablePaging, StartRowIndexParameterName, MaximumRowsParameterName, SelectCountMethod,具体名字忘了。
    也就是说用ObjectDataSource本身就支持分页操作。