DataPager.PageSize Właściwość
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Pobiera lub ustawia liczbę rekordów wyświetlanych dla każdej strony danych.
public:
property int PageSize { int get(); void set(int value); };
public int PageSize { get; set; }
member this.PageSize : int with get, set
Public Property PageSize As Integer
Wartość właściwości
Liczba rekordów wyświetlanych dla każdej strony danych. Wartość domyślna to 10.
Wyjątki
Właściwość PageSize jest ustawiona na wartość mniejszą niż 1.
Przykłady
W poniższym przykładzie pokazano, jak deklaratywnie ustawić PageSize właściwość w kontrolce DataPager i jak dynamicznie zmieniać jej wartość.
<%@ Page language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void ResultsList_SelectedIndexChanged(object sender, EventArgs e)
{
// Set the page size with the value
// selected in the DropDownList object
VendorsDataPager.PageSize = Convert.ToInt32(ResultsList.SelectedValue);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>DataPager PageSize Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>DataPager PageSize Example</h3>
<table border="0" width="640px">
<tr>
<td align="left">
<asp:Label id="ResultsLabel" runat="server"
AssociatedControlID="ResultsList" Text="Results per page:" />
<asp:DropDownList runat="server" id="ResultsList"
OnSelectedIndexChanged="ResultsList_SelectedIndexChanged" AutoPostBack="true">
<asp:ListItem Value="10" />
<asp:ListItem Value="15" Selected="True" />
<asp:ListItem Value="20" />
</asp:DropDownList>
</td>
<td align="right">
<asp:DataPager ID="VendorsDataPager" runat="server"
PagedControlID="VendorsListView" PageSize="15">
<Fields>
<asp:NumericPagerField />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
<br />
<asp:ListView ID="VendorsListView"
DataSourceID="VendorsDataSource"
runat="server">
<LayoutTemplate>
<table cellpadding="2" width="640px">
<tr runat="server" id="itemPlaceholder"></tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td>
<asp:Label ID="VendorIDLabel" runat="server" Text='<%# Eval("VendorID") %>' />
</td>
<td>
<asp:Label ID="AccountNumberLabel" runat="server" Text='<%# Eval("AccountNumber") %>' />
</td>
<td>
<asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
</td>
<td align="center">
<asp:CheckBox ID="PreferredCheckBox" runat="server"
Checked='<%# Eval("PreferredVendorStatus") %>' Enabled="False" />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the AdventureWorks sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:SqlDataSource ID="VendorsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
SelectCommand="SELECT VendorID, AccountNumber, Name, PreferredVendorStatus
FROM Purchasing.Vendor WHERE (ActiveFlag = 1)" >
</asp:SqlDataSource>
</form>
</body>
</html>
<%@ Page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub ResultsList_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
' Set the page size with the value
' selected in the DropDownList object
VendorsDataPager.PageSize = Convert.ToInt32(ResultsList.SelectedValue)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>DataPager PageSize Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>DataPager PageSize Example</h3>
<table border="0" width="640px">
<tr>
<td align="left">
<asp:Label id="ResultsLabel" runat="server"
AssociatedControlID="ResultsList" Text="Results per page:" />
<asp:DropDownList runat="server" id="ResultsList"
OnSelectedIndexChanged="ResultsList_SelectedIndexChanged" AutoPostBack="true">
<asp:ListItem Value="10" />
<asp:ListItem Value="15" Selected="True" />
<asp:ListItem Value="20" />
</asp:DropDownList>
</td>
<td align="right">
<asp:DataPager ID="VendorsDataPager" runat="server"
PagedControlID="VendorsListView" PageSize="15">
<Fields>
<asp:NumericPagerField />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
<br />
<asp:ListView ID="VendorsListView"
DataSourceID="VendorsDataSource"
runat="server">
<LayoutTemplate>
<table cellpadding="2" width="640px">
<tr runat="server" id="itemPlaceholder"></tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td>
<asp:Label ID="VendorIDLabel" runat="server" Text='<%# Eval("VendorID") %>' />
</td>
<td>
<asp:Label ID="AccountNumberLabel" runat="server" Text='<%# Eval("AccountNumber") %>' />
</td>
<td>
<asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
</td>
<td align="center">
<asp:CheckBox ID="PreferredCheckBox" runat="server"
Checked='<%# Eval("PreferredVendorStatus") %>' Enabled="False" />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the AdventureWorks sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:SqlDataSource ID="VendorsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
SelectCommand="SELECT VendorID, AccountNumber, Name, PreferredVendorStatus
FROM Purchasing.Vendor WHERE (ActiveFlag = 1)" >
</asp:SqlDataSource>
</form>
</body>
</html>
Uwagi
Użyj właściwości , PageSize aby określić rozmiar strony danych.
Jeśli na stronie znajduje się wiele DataPager kontrolek powiązanych z tą samą ListView kontrolką, należy ustawić PageSize właściwość tych kontrolek na tę samą wartość. DataPager Jeśli kontrolki mają używać różnych rozmiarów stron, ostatnia DataPager kontrolka do zainicjowania określa rzeczywisty rozmiar strony kontrolkiListView.
Dotyczy
Zobacz też
Opinia
https://aka.ms/ContentUserFeedback.
Dostępne już wkrótce: W 2024 r. będziemy stopniowo wycofywać zgłoszenia z serwisu GitHub jako mechanizm przesyłania opinii na temat zawartości i zastępować go nowym systemem opinii. Aby uzyskać więcej informacji, sprawdź:Prześlij i wyświetl opinię dla