C# GridView 分页显示

后台

::搜索用户信息::

   

                关键字:
               
               
                    权限
                    邮箱
                    状态
                    姓名
                    积分
               

               
                <%----%>
      
         
                            ForeColor="Red" GridLines="None" PageSize="5" AllowPaging="True"  
                npageindexchanging="GridViewSearchResult_PageIndexChanging" >
            <%--                            NextPageText="下一页" Position="TopAndBottom" PreviousPageText="上一页" />  --%>          
           
           
           
               
               
                <%--                    DataTextField="Title" HeaderText="标题" />--%>
               
               
               
               
               
           

           
           
           
           
           
       
  
     

 

前台

 

 List field = new List();
    protected void Page_Load(object sender, EventArgs e)
    {


        //加载CSS样式表
        WebLoader.LoadCSS(this, "BasicStyle.css");
        WebLoader.LoadCSS(this, "Search.aspx.css");

        field.Add("User_Status");
        field.Add("User_Email");
        field.Add("User_State");
        field.Add("User_RealName");
        field.Add("User_Point");

        if (!Page.IsPostBack)
        {
            this.Bind();   //调用上面的BindToGridView()绑定
        }
    }

    protected void Bind()
    {
        IUserBLL userBLL = BLLFactory.CreateUserBLL();
        IList result = userBLL.GetByFieldAndPage(field[DropDownListField.SelectedIndex], this.tbKeyword.Text.Trim(), 1, 10);


        this.GridViewSearchResult.DataSource = result;
        this.GridViewSearchResult.DataBind();
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        Bind();
       

    }


    protected void GridViewSearchResult_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.GridViewSearchResult.PageIndex = e.NewPageIndex;
        this.Bind();   //调用上面的BindToGridView()绑定
    }