天天看点

在ASP.NET中,利用GridView自定义分页

 aspx页代码:

<%@ Page Language="VB" MasterPageFile="~/products.master" EnableEventValidation="false" AutoEventWireup="false" CodeFile="more_newproducts.aspx.vb" Inherits="more_newproducts" %>

在ASP.NET中,利用GridView自定义分页

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

在ASP.NET中,利用GridView自定义分页

    <table style="width: 576px">

在ASP.NET中,利用GridView自定义分页

        <tr>

在ASP.NET中,利用GridView自定义分页

            <td style="width: 576px">

在ASP.NET中,利用GridView自定义分页

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"

在ASP.NET中,利用GridView自定义分页

        DataKeyNames="productid" GridLines="Horizontal"

在ASP.NET中,利用GridView自定义分页

        Width="576px" Font-Size="13px" HorizontalAlign="Center" CellPadding="0" AllowPaging="True">

在ASP.NET中,利用GridView自定义分页

        <Columns>

在ASP.NET中,利用GridView自定义分页

            <asp:TemplateField>

在ASP.NET中,利用GridView自定义分页

                <ItemTemplate>

在ASP.NET中,利用GridView自定义分页

                    <asp:Image ID="Image1" runat="server" Height="80px" ImageUrl='<%# "~/upload/"+Eval("s_imgurl") %>'

在ASP.NET中,利用GridView自定义分页

                        Width="80px" BorderColor="Silver" BorderStyle="Double" BorderWidth="3px" />

在ASP.NET中,利用GridView自定义分页

                </ItemTemplate>

在ASP.NET中,利用GridView自定义分页

                <ItemStyle Width="90px" />

在ASP.NET中,利用GridView自定义分页

            </asp:TemplateField>

在ASP.NET中,利用GridView自定义分页

            <asp:TemplateField HeaderText="productid" InsertVisible="False" SortExpression="productid" Visible="False">

在ASP.NET中,利用GridView自定义分页

                <ItemTemplate>

在ASP.NET中,利用GridView自定义分页

                    <asp:Label ID="lblproid" runat="server" Text='<%# Bind("productid") %>'></asp:Label>

在ASP.NET中,利用GridView自定义分页

                </ItemTemplate>

在ASP.NET中,利用GridView自定义分页

            </asp:TemplateField>

在ASP.NET中,利用GridView自定义分页

            <asp:TemplateField HeaderText="productname" SortExpression="productname" Visible="False">

在ASP.NET中,利用GridView自定义分页

                <ItemTemplate>

在ASP.NET中,利用GridView自定义分页

                    <asp:Label ID="lblproname" runat="server" Text='<%# Bind("productname") %>'></asp:Label>

在ASP.NET中,利用GridView自定义分页

                </ItemTemplate>

在ASP.NET中,利用GridView自定义分页

            </asp:TemplateField>

在ASP.NET中,利用GridView自定义分页

            <asp:TemplateField HeaderText="物品名称">

在ASP.NET中,利用GridView自定义分页

                <ItemStyle Width="206px" HorizontalAlign="Left" VerticalAlign="Middle" />

在ASP.NET中,利用GridView自定义分页

                <ItemTemplate>

在ASP.NET中,利用GridView自定义分页

                    <asp:HyperLink ID="HyperLink1" runat="server" Font-Underline="False" NavigateUrl='<%# Eval("productid", "productdetailsinfo.aspx?productid={0}") %>'

在ASP.NET中,利用GridView自定义分页

                        Text='<%# Eval("productname") %>'></asp:HyperLink>

在ASP.NET中,利用GridView自定义分页

                </ItemTemplate>

在ASP.NET中,利用GridView自定义分页

                <HeaderStyle HorizontalAlign="Left" VerticalAlign="Middle" />

在ASP.NET中,利用GridView自定义分页

            </asp:TemplateField>

在ASP.NET中,利用GridView自定义分页

            <asp:BoundField DataField="pifajia" HeaderText="价格" SortExpression="pifajia" >

在ASP.NET中,利用GridView自定义分页

                <ItemStyle Width="50px" HorizontalAlign="Center" VerticalAlign="Middle" />

在ASP.NET中,利用GridView自定义分页

                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />

在ASP.NET中,利用GridView自定义分页

            </asp:BoundField>

在ASP.NET中,利用GridView自定义分页

            <asp:BoundField DataField="pinpai" HeaderText="品牌" SortExpression="pinpai" >

在ASP.NET中,利用GridView自定义分页

                <ItemStyle Width="60px" HorizontalAlign="Center" VerticalAlign="Middle" />

在ASP.NET中,利用GridView自定义分页

                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />

在ASP.NET中,利用GridView自定义分页

            </asp:BoundField>

在ASP.NET中,利用GridView自定义分页

            <asp:BoundField DataField="changdi" HeaderText="产地" SortExpression="changdi" >

在ASP.NET中,利用GridView自定义分页

                <ItemStyle Width="70px" HorizontalAlign="Center" VerticalAlign="Middle" />

在ASP.NET中,利用GridView自定义分页

                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />

在ASP.NET中,利用GridView自定义分页

            </asp:BoundField>

在ASP.NET中,利用GridView自定义分页

            <asp:TemplateField>

在ASP.NET中,利用GridView自定义分页

                <ItemTemplate>

在ASP.NET中,利用GridView自定义分页

                    <asp:Button ID="cart" runat="server" CommandName="cart" Text="buy" Width="40px" />

在ASP.NET中,利用GridView自定义分页

                </ItemTemplate>

在ASP.NET中,利用GridView自定义分页

                <ItemStyle Width="50px" HorizontalAlign="Center" VerticalAlign="Middle" />

在ASP.NET中,利用GridView自定义分页

            </asp:TemplateField>

在ASP.NET中,利用GridView自定义分页

            <asp:TemplateField>

在ASP.NET中,利用GridView自定义分页

                <ItemTemplate>

在ASP.NET中,利用GridView自定义分页

                    <asp:Button ID="favorite" runat="server" CommandName="favorite" Text="收藏" Width="40px" />

在ASP.NET中,利用GridView自定义分页

                </ItemTemplate>

在ASP.NET中,利用GridView自定义分页

                <ItemStyle Width="50px" HorizontalAlign="Center" VerticalAlign="Middle" />

在ASP.NET中,利用GridView自定义分页

            </asp:TemplateField>

在ASP.NET中,利用GridView自定义分页

        </Columns>

在ASP.NET中,利用GridView自定义分页

        <HeaderStyle BackColor="#507CD1" ForeColor="White" Height="22px" />

在ASP.NET中,利用GridView自定义分页

        <PagerSettings Visible="False" />

在ASP.NET中,利用GridView自定义分页

    </asp:GridView>

在ASP.NET中,利用GridView自定义分页

            </td>

在ASP.NET中,利用GridView自定义分页

        </tr>

在ASP.NET中,利用GridView自定义分页

        <tr>

在ASP.NET中,利用GridView自定义分页

            <td style=" font-size :13px" align ="center"  >

在ASP.NET中,利用GridView自定义分页

                <asp:LinkButton ID="btnFirst" CommandArgument="first" OnClick="PagerButtonClick" runat="server">首 页</asp:LinkButton>

在ASP.NET中,利用GridView自定义分页

                <asp:LinkButton ID="btnPrev" CommandArgument="prev" OnClick="PagerButtonClick" runat="server">上一页</asp:LinkButton>

在ASP.NET中,利用GridView自定义分页

                <asp:LinkButton ID="btnNext" CommandArgument="next" OnClick="PagerButtonClick" runat="server">下一页</asp:LinkButton>

在ASP.NET中,利用GridView自定义分页

                <asp:LinkButton ID="btnLast" CommandArgument="last" OnClick="PagerButtonClick" runat="server">尾 页</asp:LinkButton>

在ASP.NET中,利用GridView自定义分页

                <asp:Label ID="LblCurrentIndex" runat="server"></asp:Label>

在ASP.NET中,利用GridView自定义分页

                <asp:Label ID="LblPageCount" runat="server"></asp:Label>

在ASP.NET中,利用GridView自定义分页

                <asp:Label ID="LblRecordCount" runat="server"></asp:Label>

在ASP.NET中,利用GridView自定义分页

                <asp:Label ID="LblNoRecord" runat="server" Text="记录为零" Visible="False"></asp:Label>

在ASP.NET中,利用GridView自定义分页

            </td>

在ASP.NET中,利用GridView自定义分页

        </tr>

在ASP.NET中,利用GridView自定义分页

    </table>

在ASP.NET中,利用GridView自定义分页

</asp:Content>

aspx.vb代码:

Imports System.Data

在ASP.NET中,利用GridView自定义分页

Imports System.Data.SqlClient

在ASP.NET中,利用GridView自定义分页
在ASP.NET中,利用GridView自定义分页
在ASP.NET中,利用GridView自定义分页

Partial Class more_newproductsClass more_newproducts

在ASP.NET中,利用GridView自定义分页

    Inherits System.Web.UI.Page

在ASP.NET中,利用GridView自定义分页
在ASP.NET中,利用GridView自定义分页
在ASP.NET中,利用GridView自定义分页

    Protected Sub Page_Load()Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

在ASP.NET中,利用GridView自定义分页

        GridViewBind()

在ASP.NET中,利用GridView自定义分页

    End Sub

在ASP.NET中,利用GridView自定义分页
在ASP.NET中,利用GridView自定义分页
在ASP.NET中,利用GridView自定义分页

    Protected Sub PagerButtonClick()Sub PagerButtonClick(ByVal sender As Object, ByVal e As EventArgs)

在ASP.NET中,利用GridView自定义分页
在ASP.NET中,利用GridView自定义分页

        Dim arg As String = (CType(sender, LinkButton)).CommandArgument.ToString()

在ASP.NET中,利用GridView自定义分页
在ASP.NET中,利用GridView自定义分页

        Select Case arg

在ASP.NET中,利用GridView自定义分页
在ASP.NET中,利用GridView自定义分页

            Case "prev"

在ASP.NET中,利用GridView自定义分页

                If (GridView1.PageIndex > 0) Then

在ASP.NET中,利用GridView自定义分页
在ASP.NET中,利用GridView自定义分页

                    GridView1.PageIndex -= 1

在ASP.NET中,利用GridView自定义分页

                End If

在ASP.NET中,利用GridView自定义分页
在ASP.NET中,利用GridView自定义分页

            Case "next"

在ASP.NET中,利用GridView自定义分页

                If (GridView1.PageIndex < (GridView1.PageCount - 1)) Then

在ASP.NET中,利用GridView自定义分页
在ASP.NET中,利用GridView自定义分页

  &

继续阅读