一個功能齊全的DataGrid分頁例子

來源:互聯網
上載者:User
datagrid|分頁 &lt;%@ Page language=&quot;c#&quot; EnableViewState = &quot;true&quot; Codebehind=&quot;DataGridPaging.aspx.cs&quot; AutoEventWireup=&quot;false&quot; Inherits=&quot;eMeng.Exam.DataGridPaging.DataGridPaging&quot; %&gt;&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;&gt;&lt;HTML&gt;&lt;HEAD&gt;&lt;meta content=&quot;Visual Basic 7.0&quot; name=&quot;CODE_LANGUAGE&quot;&gt;&lt;meta content=&quot;JavaScript&quot; name=&quot;vs_defaultClientScript&quot;&gt;&lt;meta content=&quot;http://schemas.microsoft.com/intellisense/ie5&quot; name=&quot;vs_targetSchema&quot;&gt;&lt;/HEAD&gt;&lt;body MS_POSITIONING=&quot;GridLayout&quot;&gt;&lt;form id=&quot;Form1&quot; runat=&quot;server&quot;&gt;&lt;asp:datagrid id=&quot;MyDataGrid&quot; runat=&quot;server&quot; AutoGenerateColumns=&quot;False&quot;HorizontalAlign=&quot;Center&quot; AlternatingItemStyle-BackColor=&quot;#eeeeee&quot;HeaderStyle-BackColor=&quot;#aaaadd&quot; Font-Size=&quot;8pt&quot; Font-Name=&quot;Verdana&quot;CellSpacing=&quot;0&quot; CellPadding=&quot;3&quot; GridLines=&quot;Both&quot; BorderWidth=&quot;1&quot;BorderColor=&quot;black&quot; OnPageIndexChanged=&quot;MyDataGrid_Page&quot; PagerStyle-HorizontalAlign=&quot;Right&quot;PagerStyle-Mode=&quot;NumericPages&quot; PageSize=&quot;5&quot; AllowPaging=&quot;True&quot;&gt; &lt;AlternatingItemStyle BackColor=&quot;#EEEEEE&quot;&gt;&lt;/AlternatingItemStyle&gt; &lt;HeaderStyle BackColor=&quot;#AAAADD&quot; Font-Bold=&quot;True&quot; HorizontalAlign=&quot;Center&quot;&gt;&lt;/HeaderStyle&gt; &lt;PagerStyle HorizontalAlign=&quot;Right&quot; Mode=&quot;NumericPages&quot;&gt;&lt;/PagerStyle&gt; &lt;Columns&gt; &lt;asp:BoundColumn HeaderText=&quot;標題&quot; DataField=&quot;Title&quot; HeaderStyle-Width=&quot;480px&quot;&gt; &lt;/asp:BoundColumn&gt; &lt;asp:BoundColumn HeaderText=&quot;發表日期&quot; DataField=&quot;CreateDate&quot; DataFormatString=&quot;{0:yyyy-MM-dd hh:mm:ss}&quot;&gt; &lt;/asp:BoundColumn&gt; &lt;/Columns&gt;&lt;/asp:datagrid&gt;&lt;p style=&quot;FONT-SIZE:9pt&quot; align=&quot;center&quot;&gt; &lt;asp:label id=&quot;lblPageCount&quot; runat=&quot;server&quot;&gt;&lt;/asp:label&gt;&nbsp; &lt;asp:label id=&quot;lblCurrentIndex&quot; runat=&quot;server&quot;&gt;&lt;/asp:label&gt; &lt;asp:linkbutton id=&quot;btnFirst&quot; onclick=&quot;PagerButtonClick&quot; runat=&quot;server&quot; Font-Name=&quot;verdana&quot; Font-size=&quot;8pt&quot; ForeColor=&quot;navy&quot; CommandArgument=&quot;0&quot;&gt;&lt;/asp:linkbutton&gt;&nbsp; &lt;asp:linkbutton id=&quot;btnPrev&quot; onclick=&quot;PagerButtonClick&quot; runat=&quot;server&quot; Font-Name=&quot;verdana&quot; Font-size=&quot;8pt&quot; ForeColor=&quot;navy&quot; CommandArgument=&quot;prev&quot;&gt;&lt;/asp:linkbutton&gt;&nbsp; &lt;asp:linkbutton id=&quot;btnNext&quot; onclick=&quot;PagerButtonClick&quot; runat=&quot;server&quot; Font-Name=&quot;verdana&quot; Font-size=&quot;8pt&quot; ForeColor=&quot;navy&quot; CommandArgument=&quot;next&quot;&gt;&lt;/asp:linkbutton&gt;&nbsp; &lt;asp:linkbutton id=&quot;btnLast&quot; onclick=&quot;PagerButtonClick&quot; runat=&quot;server&quot; Font-Name=&quot;verdana&quot; Font-size=&quot;8pt&quot; ForeColor=&quot;navy&quot; CommandArgument=&quot;last&quot;&gt;&lt;/asp:linkbutton&gt;&lt;/p&gt;&lt;/form&gt;&lt;/body&gt;&lt;/HTML&gt;using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Data.OleDb;using System.Drawing;using System.Web;using System.Web.SessionState;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;namespace eMeng.Exam.DataGridPaging{/// &lt;summary&gt;/// DataGridPaging 的摘要說明。/// &lt;/summary&gt;public class DataGridPaging : System.Web.UI.Page{ protected System.Web.UI.WebControls.DataGrid MyDataGrid; protected System.Web.UI.WebControls.Label lblPageCount; protected System.Web.UI.WebControls.Label lblCurrentIndex; protected System.Web.UI.WebControls.LinkButton btnFirst; protected System.Web.UI.WebControls.LinkButton btnPrev; protected System.Web.UI.WebControls.LinkButton btnNext; protected System.Web.UI.WebControls.LinkButton btnLast; private OleDbConnection cn = new OleDbConnection();private void Page_Load(object sender, System.EventArgs e){ // 在此處放置使用者代碼以初始化頁面 btnFirst.Text = &quot;最首頁&quot;; btnPrev.Text = &quot;前一頁&quot;; btnNext.Text =</p> <CENTER> </CENTER> <br /><br />
相關文章

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

11.11 Big Sale for Cloud

Get Unbeatable Offers with up to 90% Off,Oct.24-Nov.13 (UTC+8)

Get It Now >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

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

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