ASP.NET-GridView的分頁功能

來源:互聯網
上載者:User
ASP.NET-GridView的分頁功能2007-12-05 19:54
要實現GrdView分頁的功能。
操作如下:
1、更改GrdView控制項的AllowPaging屬性為true。
2、更改GrdView控制項的PageSize屬性為 任意數值(預設為10)
3、更改GrdView控制項的PageSetting->Mode為Numeric等(預設為Numeric)該屬性為分頁樣式。
GridView屬性設定好了,從頁面上也能看到分頁樣式。

現在開始實現分頁的功能:
1、在<<asp:GridView ID=......>後添加,OnPageIndexChanging="GridView1_PageIndexChanging"
2、在對應的aspx.cs中添加:
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        InitPage(); //重新綁定GridView資料的函數
    }
3、
GridView1.PageIndex = e.NewPageIndex;
完了之後再重新綁定一下GridView。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.