五月综合缴情婷婷六月,色94色欧美sute亚洲线路二,日韩制服国产精品一区,色噜噜一区二区三区,香港三级午夜理伦三级三

您現(xiàn)在的位置: 365建站網(wǎng) > 365文章 > 利用分頁控件AspNetPager來做數(shù)據(jù)的分頁

利用分頁控件AspNetPager來做數(shù)據(jù)的分頁

文章來源:365jz.com     點(diǎn)擊數(shù):244    更新時(shí)間:2011-05-14 14:36   參與評論

AspNetPager是第三方控件,下載地址:http://www.webdiyer.com/AspNetPagerDocs/index.html

然后通過Visaul Studio 2005的“選擇項(xiàng)”把下載后的控件DLL加載到我們的控件工具箱中。

           <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
                <Columns>
                    <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" />
                    <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" />
                    <asp:BoundField DataField="ContactName" HeaderText="ContactName" />
                    <asp:BoundField DataField="ContactTitle" HeaderText="ContactTitle" />
                    <asp:BoundField DataField="Address" HeaderText="Address" />
                    <asp:BoundField DataField="City" HeaderText="City" />
                </Columns>
            </asp:GridView>
            <webdiyer:AspNetPager ID="AspNetPager1" PageIndexBoxType="DropDownList" CustomInfoTextAlign="Left" FirstPageText="首頁"
                PrevPageText="上一頁" TextAfterPageIndexBox="頁" TextBeforePageIndexBox ="轉(zhuǎn)到" SubmitButtonText="Go"  ShowPageIndexBox ="Always" LastPageText="尾頁" NextPageText="下一頁" ShowCustomInfoSection="Left" CustomInfoHTML="當(dāng)前%CurrentPageIndex%頁,共有%PageCount%頁"
                runat="server" OnPageChanging="AspNetPager1_PageChanging">
            </webdiyer:AspNetPager>
        </div>

///

 protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bind();
        }
    }
    public void bind()
    {
        OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Northwind.mdb");
        OleDbCommand cmd = new OleDbCommand("select * from Customers", con);
        OleDbDataAdapter da = new OleDbDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;
        PagedDataSource ps = new PagedDataSource();
        ps.AllowPaging = true;
        ps.CurrentPageIndex = this.AspNetPager1.CurrentPageIndex - 1;
        ps.DataSource = ds.Tables[0].DefaultView;
        this.GridView1.DataSource = ps;
        this.GridView1.DataBind();

    }
    protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        this.AspNetPager1.CurrentPageIndex = e.NewPageIndex;
        bind();
    }

如對本文有疑問,請?zhí)峤坏浇涣髡搲?,廣大熱心網(wǎng)友會(huì)為你解答??! 點(diǎn)擊進(jìn)入論壇

發(fā)表評論 (244人查看0條評論)
請自覺遵守互聯(lián)網(wǎng)相關(guān)的政策法規(guī),嚴(yán)禁發(fā)布色情、暴力、反動(dòng)的言論。
昵稱:
最新評論
------分隔線----------------------------

其它欄目

· 建站教程
· 365學(xué)習(xí)

業(yè)務(wù)咨詢

· 技術(shù)支持
· 服務(wù)時(shí)間:9:00-18:00
365建站網(wǎng)二維碼

Powered by 365建站網(wǎng) RSS地圖 HTML地圖

copyright © 2013-2024 版權(quán)所有 鄂ICP備17013400號(hào)