C# GridView 分頁顯示

iDotNetSpace發表於2009-07-10

後臺

::搜尋使用者資訊::

   

                關鍵字:
               
               
                    許可權
                    郵箱
                    狀態
                    姓名
                    積分
               

               
                --%>
      
         
                            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部落格 ” ,連結:http://blog.itpub.net/12639172/viewspace-608858/,如需轉載,請註明出處,否則將追究法律責任。

相關文章