RadGrid for ASP.NET

RadGrid Send comments on this topic.
AlternatingItemStyle Property
See Also  Example
Telerik.WebControls Namespace > RadGrid Class : AlternatingItemStyle Property


Gets a reference to the GridTableItemStyle object that allows you to set the appearance of alternating data items in a Telerik RadGrid control.   

 

Namespace: Telerik.WebControls
Assembly: RadGrid (in RadGrid.dll)

Syntax

Visual Basic (Declaration) 
Public Overridable ReadOnly Property AlternatingItemStyle As GridTableItemStyle
Visual Basic (Usage)Copy Code
Dim instance As RadGrid
Dim value As GridTableItemStyle
 
value = instance.AlternatingItemStyle
C# 
public virtual GridTableItemStyle AlternatingItemStyle {get;}

Return Value

A reference to the GridTableItemStyle that represents the style of alternating data items in a Telerik RadGrid control.

Example

The following code example demonstrates how to use the AlternatingItemStyle property to declaratively define the style for alternating data items in a Telerik RadGrid control.
Visual BasicCopy Code
<%@ Page language="VB" %>

<%@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
  <head id="Head1" runat="server">
    <title>GridView ItemStyle and AlternatingItemStyle Example</title>
</head>
<body>
    <form id="form1" runat="server">
      <h3>GridView ItemStyle and AlternatingItemStyle Example</h3>

      <rad:RadGrid id="CustomersGridView"
        datasourceid="CustomersSource"
        autogeneratecolumns="true"
        Skin="None"
        runat="server">

        <itemstyle backcolor="LightCyan"
           forecolor="DarkBlue"
           font-italic="true"/>

        <alternatingitemstyle backcolor="PaleTurquoise"
          forecolor="DarkBlue"
          font-italic="true"/>

      </rad:RadGrid>

      <!-- This example uses Microsoft SQL Server and connects -->
      <!-- to the Northwind sample database. Use an ASP.NET -->
      <!-- expression to retrieve the connection string value -->
      <!-- from the Web.config file. -->
      <asp:sqldatasource id="CustomersSource"
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
        connectionstring="<<see cref="NorthWindConnectionString">$ ConnectionStrings</see>>"
        runat="server"/>

    
  </body>
</html>

Remarks

Use the AlternatingItemStyle property to control the appearance of alternating data items in a Telerik RadGrid control. When this property is set, the data items are displayed alternating between the ItemStyle settings and the AlternatingItemStyle settings. This property is read-only; however, you can set the properties of the GridTableItemStyle object it returns. The properties can be set declaratively using one of the following methods:

  • Place an attribute in the opening tag of the Telerik RadGrid control in the form Property-Subproperty, where Subproperty is a property of the GridTableItemStyle object (for example, AlternatingItemStyle-ForeColor).
  • Nest an <AlternatingItemStyle> element between the opening and closing tags of the Telerik RadGrid control.

The properties can also be set programmatically in the form Property.Subproperty (for example, AlternatingItemStyle.ForeColor). Common settings usually include a custom background color, foreground color, and font properties.

Requirements

Supported in: 3.0, 2.0, 1.1, 1.0 .NET Framework

See Also