GridView.AlternatingRowStyle Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Bir denetimde TableItemStyle değişen veri satırlarının görünümünü ayarlamanıza olanak tanıyan nesneye başvuru GridView 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
Bir denetimdeki TableItemStyle veri satırlarını değiştirme stilini temsil eden öğesine başvuru GridView .
- Öznitelikler
Örnekler
Aşağıdaki örnekte, bir denetimde AlternatingRowStyle değişen veri satırlarına GridView yönelik stili bildirimli olarak tanımlamak için özelliğinin nasıl kullanılacağı gösterilmektedir.
<%@ 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>
Açıklamalar
Bir denetimde AlternatingRowStyle değişen veri satırlarının GridView görünümünü denetlemek için özelliğini kullanın. Bu özellik ayarlandığında, veri satırları ayarlarla AlternatingRowStyle ayarlar arasında RowStyle dönüşümlü olarak görüntülenir. Bu özellik salt okunurdur; ancak, döndürdüğü nesnenin TableItemStyle özelliklerini ayarlayabilirsiniz. Özellikler, aşağıdaki yöntemlerden biri kullanılarak bildirim temelli olarak ayarlanabilir:
formdaki denetimin GridView açılış etiketine bir öznitelik yerleştirin; burada
Subpropertynesnenin TableItemStyle bir özelliğidir (örneğin,AlternatingRowStyle-ForeColor).Property-SubpropertyBir
<AlternatingRowStyle>öğeyi denetimin açma ve kapatma etiketleri arasında iç içe yerleştirme GridView .
Özellikler, formda Property.Subproperty program aracılığıyla da ayarlanabilir (örneğin, AlternatingRowStyle.ForeColor). Yaygın ayarlar genellikle özel bir arka plan rengi, ön plan rengi ve yazı tipi özellikleri içerir.