GridView.AlternatingRowStyle 속성

정의

TableItemStyle 컨트롤에서 데이터 행이 교대로 반복되는 모양을 설정하는 데 사용할 수 있는 GridView 개체에 대한 참조를 가져옵니다.

public:
 property System::Web::UI::WebControls::TableItemStyle ^ AlternatingRowStyle { System::Web::UI::WebControls::TableItemStyle ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.TableItemStyle AlternatingRowStyle { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.AlternatingRowStyle : System.Web.UI.WebControls.TableItemStyle
Public ReadOnly Property AlternatingRowStyle As TableItemStyle

속성 값

TableItemStyle

TableItemStyle 컨트롤에 있는 대체 데이터 행의 스타일을 나타내는 GridView에 대한 참조입니다.

특성

예제

다음 예제에서는 컨트롤에서 AlternatingRowStyle 데이터 행을 번갈아 하기 위한 스타일을 선언적으로 정의 하는 속성을 사용 하는 방법을 보여 줍니다 GridView .


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

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

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSource" 
        autogeneratecolumns="true"
        emptydatatext="No data available." 
        runat="server">
                
        <rowstyle backcolor="LightCyan"  
           forecolor="DarkBlue"
           font-italic="true"/>
                    
        <alternatingrowstyle backcolor="PaleTurquoise"  
          forecolor="DarkBlue"
          font-italic="true"/>
                            
      </asp:gridview>
            
      <!-- 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="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
        
    </form>
  </body>
</html>

<%@ Page language="VB" %>

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

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSource" 
        autogeneratecolumns="true"
        emptydatatext="No data available." 
        runat="server">
                
        <rowstyle backcolor="LightCyan"  
           forecolor="DarkBlue"
           font-italic="true"/>
                    
        <alternatingrowstyle backcolor="PaleTurquoise"  
          forecolor="DarkBlue"
          font-italic="true"/>
                            
      </asp:gridview>
            
      <!-- 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="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
        
    </form>
  </body>
</html>

설명

컨트롤에서 AlternatingRowStyle 데이터 행을 번갈아가는 GridView 모양을 제어하려면 이 속성을 사용합니다. 이 속성을 설정하면 설정과 AlternatingRowStyle 설정 간에 데이터 행이 RowStyle 번갈아 표시됩니다. 이 속성은 읽기 전용입니다. 그러나의 속성을 설정할 수는 TableItemStyle 개체를 반환 합니다. 속성은 다음 메서드 중 하나를 사용하여 선언적으로 설정할 수 있습니다.

  • 개체의 속성(예AlternatingRowStyle-ForeColor: )인 폼 Subproperty Property-Subproperty에서 컨트롤의 GridView 여는 태그에 TableItemStyle 특성을 배치합니다.

  • <AlternatingRowStyle> 컨트롤의 여는 태그와 닫는 태그 사이에 요소를 중 GridView 첩합니다.

형식에서 속성을 프로그래밍 방식으로 설정할 수도 있습니다 Property.Subproperty (예를 들어 AlternatingRowStyle.ForeColor). 일반적인 설정에는 일반적으로 사용자 지정 배경색, 전경색 및 글꼴 속성이 포함됩니다.

적용 대상

추가 정보