CSDN博客

img mdot

ASP.NET 2.0中的counterpager

发表于2004/9/28 9:56:00  713人阅读

分类: .net

ASP.NET 2.0中的counterpager,是个简单分页的轻量组件,可以指定要分页的数据源。
代码比较简单,大家一看就会了
<%@ Page Language="C#" CompileWith="Default.aspx.cs" ClassName="Default_aspx" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml" >

<head id="Head1" runat="server">

    <title>Untitled Page</title>

</head>

<body>

    <form id="form1" runat="server">

    <div>
        &nbsp;<asp:DataList ID="DataList1" Runat="server" DataKeyField="CustomerID" DataSourceID="SqlDataSource1">

            <ItemTemplate>

                CompanyName:

                <asp:Label Text='<%# Eval("CompanyName") %>' Runat="server" ID="CompanyNameLabel">

                </asp:Label><br />

            </ItemTemplate>

        </asp:DataList>

        <asp:ContentPager ID="ContentPager1" Runat="server" ControlToPaginate="DataList1" ItemsPerPage="5">

        </asp:ContentPager>

        <asp:SqlDataSource ID="SqlDataSource1" Runat="server" SelectCommand="SELECT [CustomerID], [CompanyName], [ContactName], [ContactTitle], [Address], [City], [Region] FROM [Customers]"

            ConnectionString="server=localhost;uid=sa;password=xxx;database=northwind">

        </asp:SqlDataSource>

    </div>

    </form>

</body>

</html>


 

阅读全文
0 0

相关文章推荐

img
取 消
img