GridView.RowStyle Свойство
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Получает ссылку на TableItemStyle объект, позволяющий задать внешний вид строк данных в элементе GridView управления.
public:
property System::Web::UI::WebControls::TableItemStyle ^ RowStyle { System::Web::UI::WebControls::TableItemStyle ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.TableItemStyle RowStyle { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.RowStyle : System.Web.UI.WebControls.TableItemStyle
Public ReadOnly Property RowStyle As TableItemStyle
Значение свойства
Ссылка на TableItemStyle стиль строк данных в элементе GridView управления.
- Атрибуты
Примеры
В следующем примере показано, как использовать RowStyle свойство для декларативного определения стиля строк элементов в элементе 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>
Комментарии
RowStyle Используйте свойство для управления внешним видом строк данных в элементе GridView управления. AlternatingRowStyle Если свойство также задано, строки данных отображаются чередующимися между RowStyle параметрами и AlternatingRowStyle параметрами. Это свойство доступно только для чтения; однако можно задать свойства возвращаемого TableItemStyle объекта. Свойства можно задать декларативно с помощью одного из следующих методов:
Поместите атрибут в открывающий тег GridView элемента управления в форме
Property-Subproperty, гдеSubpropertyявляется свойством TableItemStyle объекта (например,RowStyle-ForeColor).<RowStyle>Вложен элемент между открывающим и закрывающим тегами GridView элемента управления.
Свойства также можно задать программным способом в форме Property.Subproperty (например, RowStyle.ForeColor). Общие параметры обычно включают настраиваемый цвет фона, цвет переднего плана и свойства шрифта.