Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]ASP.NET WebForms Controls
 [Collapse]ASP.NET MVC Extensions
  [Expand]Product Information
  [Expand]Getting Started
  [Expand]Common Concepts
  [Collapse]Grid View
    Overview - GridView
    Main Features - GridView
   [Collapse]Concepts
    [Expand]Binding to Data
    [Collapse]Data Representation Basics
     [Expand]Cells
     [Expand]Columns
     [Collapse]Rows
       Traversing Rows
       Preview Row
      Customization Window
    [Expand]Focus and Navigation
    [Expand]Data Editing and Validation
    [Expand]Exporting
   [Expand]Visual Elements
   [Expand]Member Tables
   [Expand]Examples
  [Expand]Tree List
  [Expand]Card View
  [Expand]Reporting
  [Expand]Charting
  [Expand]Pivot Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Scheduler
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Vertical Grid
  [Expand]Data Editors Extensions
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Extensions
  [Expand]SpellChecker
  [Expand]Query Builder
 [Expand]Localization
 [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]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Traversing Rows

This topic describes how to traverse through (access one by one) rows displayed within the GridView. The topic consists of the following sections.

Expanded Row Customization

The GridView extension 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 and templates, or perform required calculations.

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

Both events provide the same set of parameters, allowing you to identify the currently processed row's type, visible index, key value, etc.

Note

Important:
When GridView is being rendered, data binding is not allowed. Thus, if you need to obtain the processed row's values when handling these events, refrain from using methods provided by GridView (e.g., ASPxGridView.GetRow (via MVCxGridView.GetRow), ASPxGridView.GetRowValues (via MVCxGridView.GetRowValues), ASPxGridView.GetCurrentPageRowValues (via MVCxGridView.GetCurrentPageRowValues), etc.). Instead, use the ASPxGridViewTableRowEventArgs.GetValue method provided by the event parameter. To obtain the values of other rows (not currently being processed), use the methods provided by the data model.

The code sample below demonstrates how to change the style of a row based on one of its values.

View code:

The image below illustrates the result.

Expanded Rows Displayed within the Current Page

On the Server Side

GridView provides the ASPxGridView.GetCurrentPageRowValues (via MVCxGridView.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.

The code sample below demonstrates how to get a list of values displayed within the visible rows.

View code:

The image below illustrates the format of the returned values.

On the Client Side

On the client side, you can use the ASPxClientGridView.GetPageRowValues method as an alternative to the MVCxGridView.GetCurrentPageRowValues server method.

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