ITPub博客

首页 > Linux操作系统 > Linux操作系统 > C# GridView 分页显示

C# GridView 分页显示

原创 Linux操作系统 作者:iDotNetSpace 时间:2009-07-10 17:49:29 0 删除 编辑

后台

::搜索用户信息::

   

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

               
                <%----%>
      
         
                            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()绑定
    }

 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12639172/viewspace-608858/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: GridView导入至EXCEL
请登录后发表评论 登录
全部评论

注册时间:2008-01-04

  • 博文量
    2376
  • 访问量
    5766304