Skip to main content
Tab

GridViewTemplates.StatusBar Property

Specifies a template to display the status bar.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.2.dll

NuGet Package: DevExpress.Web

#Declaration

[DefaultValue(null)]
public virtual ITemplate StatusBar { get; set; }

#Property Value

Type Default Description
ITemplate null

An object that implements the ITemplate interface.

#Remarks

Set the ShowStatusBar property to Visible to show the status bar.

When you specify the StatusBar property, the control creates a template within a container object of the GridViewStatusBarTemplateContainer type.

Refer to the Create Templates topic for information on how to create templates for the Grid View control’s elements.

#Example

The code sample below adds a custom pager to the status bar template.

<dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" KeyFieldName="CustomerID"
    OnCustomCallback="grid_CustomCallback">
    <Columns><%--...--%></Columns>
    <Settings ShowStatusBar="Visible" />
    <SettingsPager Visible="false" />
    <Templates>
        <StatusBar>
        <div style="text-align:right;">
            Records per page: 
            <select onchange="window.grid.PerformCallback(this.value);" >
                <option value="5" <%# WriteSelectedIndex(5) %> >5</option>
                <option value="10"<%# WriteSelectedIndex(10) %>  >10</option>
                <option value="15" <%# WriteSelectedIndex(15) %> >15</option>
                <option value="20" <%# WriteSelectedIndex(20) %> >20</option>
                <option value="25" <%# WriteSelectedIndex(25) %> >25</option>
            </select>&nbsp;
            <%#GetShowingOnPage() %>&nbsp;
              <a title="First" href="JavaScript:grid.GotoPage(0);">&lt;&lt;</a> &nbsp; 
              <a title="Prev" href="JavaScript:grid.PrevPage();">&lt;</a> &nbsp;
            Page <input type="text"
              onchange="if(!grid.InCallback())
                grid.GotoPage(parseInt(this.value, 10) - 1)"
              onkeydown="if (event.keyCode == 13) {
                event.cancelBubble=true;
                event.returnValue = false;
                grid.GotoPage(parseInt(this.value, 10) - 1);
                return false; }"
              value="<%# grid.PageIndex + 1 %>" style="width:20px" /> of <%# grid.PageCount %> &nbsp;
              <a title="Next" href="JavaScript:grid.NextPage();">&gt;</a> &nbsp;
              <a title="Last" href="JavaScript:grid.GotoPage(<%# grid.PageCount - 1 %>);">&gt;&gt;</a> &nbsp; 
        </div>
        </StatusBar>
    </Templates>
</dx:ASPxGridView>
using System;
using System.Data;
using System.Configuration;
using DevExpress.Web.ASPxGridView;

public partial class Grid_ColumnResizing_OverflowHidden_DataItemTemplate : System.Web.UI.Page {
    const string GridCustomPageSizeName = "gridCustomPageSize";
    protected void Page_Init(object sender, EventArgs e) {
        if(Session[GridCustomPageSizeName] != null) {
            grid.SettingsPager.PageSize = (int)Session[GridCustomPageSizeName];
        }
    }
    protected void grid_CustomCallback(object sender,  ASPxGridViewCustomCallbackEventArgs e) {
        int newPageSize;
        if(!int.TryParse(e.Parameters, out newPageSize)) return;
        grid.SettingsPager.PageSize = newPageSize;
        Session[GridCustomPageSizeName] = newPageSize;
        grid.DataBind();
    }
    protected string WriteSelectedIndex(int pageSize) {
        return pageSize == grid.SettingsPager.PageSize ? "selected='selected'" : string.Empty;
    }
    protected string GetShowingOnPage() {
        int pageSize = grid.SettingsPager.PageSize;
        int startIndex = grid.PageIndex * pageSize + 1;
        int endIndex = (grid.PageIndex + 1) * pageSize;
        if(endIndex > grid.VisibleRowCount) {
            endIndex = grid.VisibleRowCount;
        }
        return string.Format("Showing {0}-{1} of {2}", startIndex, endIndex, grid.VisibleRowCount);
    }
}
See Also