aspnet-devexpress-dot-web-dot-aspxgridviewpagersettings-98776322.md
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
[DefaultValue(10)]
public int PageSize { get; set; }
<DefaultValue(10)>
Public Property PageSize As Integer
| Type | Default | Description |
|---|---|---|
| Int32 | 10 |
An integer value that specifies the number of rows.
|
You can access this nested property as listed below:
| Library | Object Type | Path to PageSize |
|---|---|---|
| ASP.NET MVC Extensions | GridViewSettings |
.SettingsPager .PageSize
| | MVCxGridViewProperties |
.SettingsPager .PageSize
| | ASP.NET Web Forms Controls | ASPxGridView |
.SettingsPager .PageSize
| | GridViewProperties |
.SettingsPager .PageSize
|
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.
Web Forms approach:
<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:
@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()
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
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
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
ASPxGridViewPagerSettings Class