DetailsView.AlternatingRowStyle Özellik

Tanım

Bir denetimdeki TableItemStyle değişen veri satırlarının görünümünü ayarlamanıza olanak tanıyan bir DetailsView nesne başvurusu alır.

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

Özellik Değeri

Denetimdeki TableItemStyle değişen veri satırlarının stilini temsil eden öğesine başvuru DetailsView .

Öznitelikler

Örnekler

Aşağıdaki kod örneği, denetimin AlternatingRowStyle değişen veri satırları DetailsView için yazı tipi ve stil ayarlarını belirtmek için özelliğinin nasıl kullanılacağını gösterir.

<%@ 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>DetailsView RowStyle and AlternatingRowStyle Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView RowStyle and AlternatingRowStyle Example</h3>
                
        <asp:detailsview id="CustomersView"
          datasourceid="Customers"
          autogeneraterows="true"
          allowpaging="true" 
          runat="server">
               
          <headerstyle backcolor="Navy"
            forecolor="White"/>
            
          <RowStyle BackColor="LightGray"
            ForeColor="Blue"
            Font-Names="Arial"
            Font-Size="10"
            Font-Italic="true"/>
            
          <AlternatingRowStyle BackColor="White"
            ForeColor="Blue"
            Font-Names="Arial"
            Font-Size="10"
            Font-Italic="true"/>
                    
        </asp:detailsview>
            
        <!-- This example uses Microsoft SQL Server and connects -->
        <!-- to the Northwind sample database. -->           
        <asp:SqlDataSource ID="Customers" runat="server" 
          ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
          SelectCommand="SELECT [CompanyName], [ContactName], [CustomerID], [Phone] FROM [Customers]">
        </asp:SqlDataSource>
            
      </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>DetailsView RowStyle and AlternatingRowStyle Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView RowStyle and AlternatingRowStyle Example</h3>
                
        <asp:detailsview id="CustomersView"
          datasourceid="Customers"
          autogeneraterows="true"
          allowpaging="true" 
          runat="server">
               
          <headerstyle backcolor="Navy"
            forecolor="White"/>
            
          <RowStyle BackColor="LightGray"
            ForeColor="Blue"
            Font-Names="Arial"
            Font-Size="10"
            Font-Italic="true"/>
            
          <AlternatingRowStyle BackColor="White"
            ForeColor="Blue"
            Font-Names="Arial"
            Font-Size="10"
            Font-Italic="true"/>
                    
        </asp:detailsview>
            
        <!-- This example uses Microsoft SQL Server and connects -->
        <!-- to the Northwind sample database. -->           
        <asp:SqlDataSource ID="Customers" runat="server" 
          ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
          SelectCommand="SELECT [CompanyName], [ContactName], [CustomerID], [Phone] FROM [Customers]">
        </asp:SqlDataSource>
            
      </form>
  </body>
</html>

Açıklamalar

Bir denetimde AlternatingRowStyle değişen veri satırlarının DetailsView görünümünü denetlemek için özelliğini kullanın. Bu özellik ayarlandığında, ayarlarla AlternatingRowStyle ayarlar arasında RowStyle değişen veri satırları görüntülenir. Bu özellik salt okunurdur; ancak, döndürdüğü nesnenin TableItemStyle özelliklerini ayarlayabilirsiniz. Özellikler biçiminde bildirimli olarak Property-Subpropertyayarlanabilir; burada Subproperty nesnenin TableItemStyle bir özelliğidir (örneğin, AlternatingRowStyle-ForeColor). Özellikler, formda Property.Subproperty program aracılığıyla da ayarlanabilir (örneğin, AlternatingRowStyle.ForeColor). Genel ayarlar genellikle özel bir arka plan rengi, ön plan rengi ve yazı tipi özelliklerini içerir.

Şunlara uygulanır

Ayrıca bkz.