asp.net實現access資料庫分頁

來源:互聯網
上載者:User

標籤:des   style   blog   http   color   os   for   資料   

最近在編程人生上看到篇文章很有感觸,覺得人生還是要多奮鬥。今天給大家貢獻點乾貨。

<divclass="page"id="ctrlRecordPage">總<asp:LabelID="Zpage"runat="server"Text="1"></asp:Label>頁/<asp:LabelID="Zcount"runat="server"Text="0"></asp:Label>條<asp:LinkButtonID="start_button"runat="server"onclick="start_button_Click">首頁</asp:LinkButton><asp:LinkButtonID="up_button"runat="server"onclick="up_button_Click">上一頁</asp:LinkButton><asp:LinkButtonID="down_button"runat="server"onclick="down_button_Click">下一頁</asp:LinkButton><asp:LinkButton ID="end_button" runat="server" onclick="end_button_Click">末頁</asp:LinkButton>&nbsp;&nbsp;每頁<asp:TextBoxID="Pagesize"runat="server"Text="10"Width="30px"></asp:TextBox>條當前<asp:DropDownListID="Pageing"runat="server"AutoPostBack="True"onselectedindexchanged="Pageing_SelectedIndexChanged"></asp:DropDownList>頁</div>privatevoidPageing_databird(intvalue){Pageing.Items.Clear();intzdatapage=Convert.ToInt32(Zpage.Text);if(zdatapage>0){for(inti=1;i<=zdatapage;i++){Pageing.Items.Add(i.ToString());}}else{Pageing.Items.Add("1");}if(Pageing.Items.FindByValue(value.ToString())!=null)Pageing.SelectedValue=value.ToString();if(zdatapage>1){Pageing.Enabled=true;intdatapageing=Convert.ToInt32(Pageing.SelectedValue);if(datapageing>1){start_button.Enabled=true;up_button.Enabled=true;}else{start_button.Enabled=false;up_button.Enabled=false;}if(datapageing<zdatapage){down_button.Enabled=true;end_button.Enabled=true;}else{down_button.Enabled=false;end_button.Enabled=false;}}else{start_button.Enabled=false;up_button.Enabled=false;down_button.Enabled=false;end_button.Enabled=false;Pageing.Enabled=false;}}protectedvoidstart_button_Click(objectsender,EventArgse){intdatapageing=1;if(Pageing.Items.FindByValue(datapageing.ToString())!=null)Pageing.SelectedValue=datapageing.ToString();DataBird();}protectedvoidup_button_Click(objectsender,EventArgse){intdatapageing=Convert.ToInt32(Pageing.SelectedValue);if(datapageing>1)datapageing--;if(Pageing.Items.FindByValue(datapageing.ToString())!=null)Pageing.SelectedValue=datapageing.ToString();DataBird();}protectedvoiddown_button_Click(objectsender,EventArgse){intdatapageing=Convert.ToInt32(Pageing.SelectedValue);intzdatapage=Convert.ToInt32(Zpage.Text);if(datapageing<zdatapage)datapageing++;if(Pageing.Items.FindByValue(datapageing.ToString())!=null)Pageing.SelectedValue=datapageing.ToString();DataBird();}protectedvoidend_button_Click(objectsender,EventArgse){intzdatapage=Convert.ToInt32(Zpage.Text);if(Pageing.Items.FindByValue(zdatapage.ToString())!=null)Pageing.SelectedValue=zdatapage.ToString();DataBird();}protectedvoidPageing_SelectedIndexChanged(objectsender,EventArgse){DataBird();}protectedvoidDataBird(){dc.Setsql="select*fromadlistorderbycreatetimedesc";DataTabledt=dc.GetDataTable(0);PagedDataSourcepds=newPagedDataSource();pds.DataSource=dt.DefaultView;pds.AllowPaging=true;intdatapagesize=10;if(Convert.ToInt32(Pagesize.Text)>0)datapagesize=Convert.ToInt32(Pagesize.Text);pds.PageSize=datapagesize;Zcount.Text=pds.DataSourceCount.ToString();Zpage.Text = pds.PageCount.ToString();intzpaging=1;if(Pageing.SelectedIndex>-1)zpaging=Convert.ToInt32(Pageing.SelectedValue);Pageing_databird(zpaging);pds.CurrentPageIndex=Convert.ToInt32(Pageing.SelectedValue)-1;listshow_Repeater.DataSource=pds;listshow_Repeater.DataBind();}

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.