GridView.PageSize 속성

정의

GridView 컨트롤의 페이지에 표시할 레코드의 수를 가져오거나 설정합니다.

public:
 virtual property int PageSize { int get(); void set(int value); };
public virtual int PageSize { get; set; }
member this.PageSize : int with get, set
Public Overridable Property PageSize As Integer

속성 값

Int32

단일 페이지에 표시할 레코드의 수입니다. 기본값은 10입니다.

예외

PageSize 속성이 1보다 작은 값으로 설정된 경우

예제

다음 예제에서는 컨트롤에서 PageSize 한 번에 GridView 15 개의 레코드를 표시 하는 속성을 사용 하는 방법을 보여 줍니다.


<%@ Page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>GridView PageSize Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView PageSize Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSource" 
        autogeneratecolumns="true"
        emptydatatext="No data available." 
        allowpaging="true" 
        pagesize="15"
        runat="server">
                
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects  -->
      <!-- to the Northwind sample database. Use an ASP.NET     -->
      <!-- expression to retrieve the connection string value   -->
      <!-- from the Web.config file.                            -->
      <asp:sqldatasource id="CustomersSource"
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
        
    </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">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>GridView PageSize Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView PageSize Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSource" 
        autogeneratecolumns="true"
        emptydatatext="No data available." 
        allowpaging="true" 
        pagesize="15"
        runat="server">
                
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects  -->
      <!-- to the Northwind sample database. Use an ASP.NET     -->
      <!-- expression to retrieve the connection string value   -->
      <!-- from the Web.config file.                            -->
      <asp:sqldatasource id="CustomersSource"
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
        
    </form>
  </body>
</html>

설명

페이징 기능을 사용하도록 설정하면(속성을 true설정 AllowPaging 하여) 속성을 사용하여 PageSize 단일 페이지에 표시할 레코드 수를 지정합니다.

적용 대상

추가 정보