[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Collapse]Grid View
   [Expand]Product Information
    Getting Started
    [Expand]Binding to Data
    [Collapse]Data Representation Basics
       Traversing Rows
     [Expand]Customization Window
     [Expand]Context Menu Overview
      Customization Dialog
    [Expand]Focus and Navigation
    [Expand]Data Editing
    [Expand]Data Shaping and Manipulation
    [Expand]Data Formatting
    [Expand]Master-Detail Relationship
     Appearance Customization
     Save and Restore Layout
    ASPxGridView Designer
   [Expand]Visual Elements
   [Expand]Member Tables
   [Expand]ASPxGridView - Animated Images
  [Expand]Tree List
  [Expand]Card View
  [Expand]Chart Control
  [Expand]Pivot Grid
  [Expand]Rich Text Editor
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Controls
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Traversing Rows

This topic describes how to traverse (access one by one) through rows displayed within ASPxGridView. This includes:

  1. Rows Displayed Within the Current Page
  2. Visible Rows
  3. All Data Rows

Expanded Rows Displayed Within the Current Page

ASPxGridView provides two server-side events that fire for each row (data row, group row, etc.) before it is rendered onscreen, and enable you to customize its style, templates, or perform required calculations. These are:

  • ASPxGridView.HtmlRowCreated - this event is raised for each row, displayed within the current page, when the corresponding HTML table row has been created. You can handle this event, for example, to initialize web controls contained within grid templates.
  • ASPxGridView.HtmlRowPrepared - this event is raised for each row, displayed within the current page, when the corresponding HTML table row has been prepared but isn't yet rendered. You can handle this event to change the style settings of individual rows.

Both events provide the same set of parameters that allow you to identify the currently processed row's type, visible index, key value, etc. For an example, see How to: Dynamically Change Images Displayed Within Data Cells.

Important Note:

ASPxGridView provides the ASPxGridView.GetCurrentPageRowValues method, which returns row values displayed within the current page. The method's parameter allows you to specify data source fields whose values should be returned.

In some instances, however, it is needed to traverse through current page rows one by one. If data is grouped, the current page can contain both data and group rows. To identify whether data grouping is applied, check the number of grouped columns.

Data and group rows displayed within the grid can be identified by their visible indexes. To traverse through the current page rows, you need to obtain the starting and ending visible indices.

Expanded Visible Rows

The number of visible rows is returned by the grid's ASPxGridView.VisibleRowCount property. This includes both data rows and group rows (if data grouping is applied). Data and group rows contained within collapsed groups are not counted. End-users can see the number of visible rows within the grid's Pager.

The following code shows how to traverse through all visible rows one by one.

Expanded All Data Rows

If ASPxGridView displayed all records from the bound data source (data isn't grouped or filtered), you can process all data rows as shown in the Visible Rows section. Otherwise, use methods provided by the data source to access its records one by one.

Is this topic helpful?​​​​​​​