<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
CssClass="grid" AllowPaging="True" DataKeyNames="orderNO" PageSize="5"
onpageindexchanged="GridView1_PageIndexChanged"
onpageindexchanging="GridView1_PageIndexChanging">
<Columns>
<asp:BoundField DataField="field1" HeaderText="名称" ReadOnly="True" />
<asp:BoundField DataField="field2" HeaderText="名称" />
<asp:BoundField DataField="field3" HeaderText="名称" />
<asp:BoundField DataField="field4" HeaderText="名称" />
<asp:BoundField DataField="field5" HeaderText="名称" />
</Columns>
<PagerTemplate>
<br/>
<asp:Label ID="lblPage" runat="server" Text='<%# "第" + (((GridView)Container.NamingContainer).PageIndex + 1) + "页/共" + (((GridView)Container.NamingContainer).PageCount) + "页" %> '></asp:Label>
<asp:LinkButton ID="lbnFirst" runat="Server" Text="首页" Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>' CommandName="Page" CommandArgument="First" ></asp:LinkButton>
<asp:LinkButton ID="lbnPrev" runat="server" Text="上一页" Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>' CommandName="Page" CommandArgument="Prev" ></asp:LinkButton>
<asp:LinkButton ID="lbnNext" runat="Server" Text="下一页" Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != (((GridView)Container.NamingContainer).PageCount - 1) %>' CommandName="Page" CommandArgument="Next" ></asp:LinkButton>
<asp:LinkButton ID="lbnLast" runat="Server" Text="尾页" Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != (((GridView)Container.NamingContainer).PageCount - 1) %>' CommandName="Page" CommandArgument="Last" ></asp:LinkButton>
<br />
</PagerTemplate>
</asp:GridView>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindRepeater();
}
}
private void BindRepeater()
{
string userId = "1";
DataTable dt = BankService.GetOrderListByUId(userId);
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
this.GridView1.PageIndex = e.NewPageIndex;
}
protected void GridView1_PageIndexChanged(object sender, EventArgs e)
{
BindRepeater();
}