Fork me on GitHub

AspNetPager 示例 - 使用图片按钮

该示例演示如何在AspNetPager分页控件中使用图片按钮。
订单编号订单日期公司名称雇员姓名
110771998/5/6Rattlesnake Canyon GroceryNancy Davolio
110761998/5/6Bon app'Margaret Peacock
110751998/5/6Richter SupermarktLaura Callahan
110741998/5/6Simons bistroRobert King
110731998/5/5Pericles Comidas clásicasAndrew Fuller
110721998/5/5Ernst HandelMargaret Peacock
110711998/5/5LILA-SupermercadoNancy Davolio
110701998/5/5Lehmanns MarktstandAndrew Fuller
110691998/5/4Tortuga RestauranteNancy Davolio
110681998/5/4Queen CozinhaLaura Callahan
  

ImageButtons.aspx:

<%@ Page Language="C#" AutoEventWireup="true"  MetaDescription="该示例演示如何在AspNetPager分页控件中使用图片按钮。" Inherits="ImageButtons_Default" MasterPageFile="AspNetPager.master" Title="使用图片按钮" Codebehind="ImageButtons.aspx.cs" %>

<asp:Content runat="server" ID="content1" ContentPlaceHolderID="main">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="100%" CssClass="table table-bordered table-striped">
            <Columns>
                <asp:BoundField DataField="orderid" HeaderText="订单编号" />
                <asp:BoundField DataField="orderdate" HeaderText="订单日期" DataFormatString="{0:d}" />
                <asp:BoundField DataField="companyname" HeaderText="公司名称" />
                <asp:BoundField DataField="employeename" HeaderText="雇员姓名" />
            </Columns>
    </asp:GridView>
    <webdiyer:aspnetpager id="AspNetPager1" runat="server" horizontalalign="Center"
        pagingbuttontype="Image" width="100%" ImagePath="images/" ButtonImageNameExtension="n" ButtonImageExtension=".gif" 
        DisabledButtonImageNameExtension="g" CpiButtonImageNameExtension="r" PagingButtonSpacing="10px" ButtonImageAlign="left"
        OnPageChanged="AspNetPager1_PageChanged"></webdiyer:aspnetpager>
</asp:Content>

ImageButtons.aspx.cs:

using System;
using System.Collections.Generic;
using System.Web.UI;
using Webdiyer.HomePage.AspNetPagerDemo;

public partial class ImageButtons_Default : Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            AspNetPager1.RecordCount = OrderDAL.GetOrderCount();
            bindData();
        }
    }

    void bindData()
    {
        List<Order> orders = OrderDAL.GetPagedOrders(AspNetPager1.StartRecordIndex, AspNetPager1.EndRecordIndex);
        GridView1.DataSource = orders;
        GridView1.DataBind();
    }

    protected void AspNetPager1_PageChanged(object src,EventArgs e)
    {
        bindData();
    }
}