This documentation is archived and is not being maintained.

GridViewRow.RowType Property

Gets the row type of the GridViewRow object.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public virtual DataControlRowType RowType { get; set; }
/** @property */
public DataControlRowType get_RowType ()

/** @property */
public void set_RowType (DataControlRowType value)

public function get RowType () : DataControlRowType

public function set RowType (value : DataControlRowType)

Not applicable.

Property Value

One of the DataControlRowType values.

Use the RowType property to determine the type of row that the GridViewRow object represents. The following table lists the different row type values.

Row type



A data row in the GridView control.


The footer row in the GridView control.


The header row in the GridView control.


The empty row in the GridView control. The empty row is displayed when GridView control does not have any records to display.


A pager row in the GridView control.


A separator row in the GridView control.

This property is commonly used to determine a row's type before performing an operation.

The following example demonstrates how to use the RowType property to determine whether a row being created is a footer row. If the row is a footer row, the value for the sum of the column is updated into the footer row.

<%@ Page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<script runat="server">
  // Create a variable to store the order total.
  private Decimal orderTotal = 0.0M;

  void OrderGridView_RowCreated(Object sender, GridViewRowEventArgs e)
    // Retrieve the current row. 
    GridViewRow row = e.Row;
    // Update the column total if the row being created is
    // a footer row.
    if (row.RowType == DataControlRowType.Footer)
      // Get the OrderTotalTotal Label control in the footer row.
      Label total = (Label)e.Row.FindControl("OrderTotalLabel");
      // Display the grand total of the order formatted as currency.
      if (total != null)
        total.Text = orderTotal.ToString("c");
  void OrderGridView_RowDataBound(Object sender, GridViewRowEventArgs e)
    // Retrieve the current row. 
    GridViewRow row = e.Row;
    // Add the field value to the column total if the row being created is
    // a data row. 
    if (row.RowType == DataControlRowType.DataRow)
      // Get the cell that contains the item total.
      TableCell cell = e.Row.Cells[2];
      // Get the DataBoundLiteralControl control that contains the 
      // data bound value.
      DataBoundLiteralControl boundControl = (DataBoundLiteralControl)cell.Controls[0];
      // Remove the '$' character for the type converter to work properly.
      String itemTotal = boundControl.Text.Replace("$",  "");
      // Add the total for an item (row) to the order total.
      orderTotal += Convert.ToDecimal(itemTotal);

<html xmlns="" >
  <head runat="server">
    <title>GridViewRow RowType Example</title>
    <form id="form1" runat="server">
      <h3>GridViewRow RowType Example</h3>

      <!-- Populate the Columns collection declaratively. -->
      <!-- Create a custom TemplateField column that uses      -->
      <!-- two Label controls to display an author's first and -->
      <!-- last name in the same column.                       -->
      <asp:gridview id="OrderGridView" 
          <asp:boundfield datafield="UnitPrice"
            headertext="Unit Price" 
          <asp:boundfield datafield="Quantity"
          <asp:templatefield headertext="Total"
              <%#Eval("Total", "{0:c}") %>
              <asp:label id="OrderTotalLabel"
      <!-- This example uses Microsoft SQL Server and connects -->
      <!-- to the Northwind sample database.                   -->
      <asp:sqldatasource id="OrderSqlDataSource"  
        selectcommand="SELECT [OrderID], [UnitPrice], [Quantity], [UnitPrice]*[Quantity] As [Total] FROM [order details] WHERE [OrderID]=10248"
        connectionstring="server=localhost;database=northwind;integrated security=SSPI"

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0