Back to Devexpress

ASPxGridViewPagerSettings.PageSize Property

aspnet-devexpress-dot-web-dot-aspxgridviewpagersettings-98776322.md

latest6.5 KB
Original Source

ASPxGridViewPagerSettings.PageSize Property

Gets or sets the maximum number of rows that can be displayed on a page.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
[DefaultValue(10)]
public int PageSize { get; set; }
vb
<DefaultValue(10)>
Public Property PageSize As Integer

Property Value

TypeDefaultDescription
Int3210

An integer value that specifies the number of rows.

|

Property Paths

You can access this nested property as listed below:

LibraryObject TypePath to PageSize
ASP.NET MVC ExtensionsGridViewSettings

.SettingsPager .PageSize

| | MVCxGridViewProperties |

.SettingsPager .PageSize

| | ASP.NET Web Forms Controls | ASPxGridView |

.SettingsPager .PageSize

| | GridViewProperties |

.SettingsPager .PageSize

|

Remarks

Use the PageSize property to specify the maximum number of rows that can be displayed on a page. To display all the rows in a grid, set the ASPxGridViewPagerSettings.Mode property to GridViewPagerMode.ShowAllRecords. In this case, the PageSize property is not in effect.

Users can change the page size by using the page size item element. To display all rows in a grid, end-users can click the All item in the page size item dropdown window, or click the All navigation button.

When a grid page size is changed by end-user interactions, the ASPxGridBase.PageSizeChanged event fires.

Note

When a grid displays all rows, the PageSize property returns the last specified numerical value.

Online Demos

Example

Web Forms approach:

aspx
<dx:ASPxGridView ID="Grid" runat="server" AutoGenerateColumns="False" Width="100%" DataSourceID="OrdersDataSource" KeyFieldName="OrderID">
    <Columns>
    ...
    </Columns>
    <Settings VerticalScrollableHeight="300" />
    <SettingsPager PageSize="20">
        <PageSizeItemSettings Visible="true" ShowAllItem="true" />
    </SettingsPager>
</dx:ASPxGridView>

MVC approach:

razor
@Html.DevExpress().GridView(settings => {
    settings.Name = "gvScrolling";

    settings.Settings.HorizontalScrollBarMode = ScrollBarMode.Visible;
    settings.Settings.VerticalScrollBarMode = ScrollBarMode.Visible;
    settings.Settings.VerticalScrollableHeight = 200;
    settings.SettingsPager.PageSize = 20;
    ...
}).Bind(Model).GetHtml()

Online Example

View Example: How to create a custom pager and display a page size item

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the PageSize property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

asp-net-web-forms-grid-cache-data-on-the-client-side/CS/Solution/Default.aspx.cs#L8

csharp
protected void grid_CustomJSProperties(object sender, ASPxGridViewClientJSPropertiesEventArgs e) {
    int startIndex = grid.PageIndex * grid.SettingsPager.PageSize;
    int end = Math.Min(grid.VisibleRowCount, startIndex + grid.SettingsPager.PageSize);

asp-net-web-forms-grid-cache-data-on-the-client-side/VB/Solution/Default.aspx.vb#L13

vb
Protected Sub grid_CustomJSProperties(ByVal sender As Object, ByVal e As ASPxGridViewClientJSPropertiesEventArgs)
    Dim startIndex As Integer = grid.PageIndex * grid.SettingsPager.PageSize
    Dim [end] As Integer = Math.Min(grid.VisibleRowCount, startIndex + grid.SettingsPager.PageSize)

See Also

Mode

Grid View

ASPxGridViewPagerSettings Class

ASPxGridViewPagerSettings Members

DevExpress.Web Namespace