DataControlField.ItemStyle Свойство
Определение
Возвращает стиль любого текстового содержимого, отображаемого полем элемента управления содержанием.Gets the style of any text-based content displayed by a data control field.
public:
property System::Web::UI::WebControls::TableItemStyle ^ ItemStyle { System::Web::UI::WebControls::TableItemStyle ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.TableItemStyle ItemStyle { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.ItemStyle : System.Web.UI.WebControls.TableItemStyle
Public ReadOnly Property ItemStyle As TableItemStyle
Значение свойства
TableItemStyle, управляющий видом текст, отображенного в DataControlField.A TableItemStyle that governs the appearance of text displayed in a DataControlField.
- Атрибуты
Примеры
В следующем примере кода показано, как декларативно задать ItemStyle свойство для объектов, BoundField используемых для отображения FirstName
и LastName
данных в DetailsView элементе управления.The following code example demonstrates how to declaratively set the ItemStyle property on the BoundField objects used to display FirstName
and LastName
data in a DetailsView control. DetailsViewЭлемент управления имеет AutoGenerateRows свойство, для которого задано значение false
, которое позволяет ему отображать подмножество данных, возвращаемых SelectCommand свойством.The DetailsView control has the AutoGenerateRows property set to false
, which enables it to display a subset of the data returned by the SelectCommand property.
<%@ 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>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:sqldatasource
id="SqlDataSource1"
runat="server"
connectionstring="<%$ ConnectionStrings:MyNorthwind%>"
selectcommand="Select * From Employees">
</asp:sqldatasource>
<asp:detailsview
id="DetailsView1"
runat="server"
allowpaging="True"
datasourceid="SqlDataSource1"
height="208px"
width="264px"
autogeneraterows="False">
<fields>
<asp:boundfield
sortexpression="LastName"
datafield="LastName"
headertext="LastName">
<itemstyle backcolor="Yellow">
</itemstyle>
</asp:boundfield>
<asp:boundfield
sortexpression="FirstName"
datafield="FirstName"
headertext="FirstName">
<itemstyle forecolor="#C00000">
</itemstyle>
</asp:boundfield>
<asp:buttonfield
text="TestButton"
buttontype="Button">
</asp:buttonfield>
</fields>
</asp:detailsview>
</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>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:sqldatasource
id="SqlDataSource1"
runat="server"
connectionstring="<%$ ConnectionStrings:MyNorthwind%>"
selectcommand="Select * From Employees">
</asp:sqldatasource>
<asp:detailsview
id="DetailsView1"
runat="server"
allowpaging="True"
datasourceid="SqlDataSource1"
height="208px"
width="264px"
autogeneraterows="False">
<fields>
<asp:boundfield
sortexpression="LastName"
datafield="LastName"
headertext="LastName">
<itemstyle backcolor="Yellow">
</itemstyle>
</asp:boundfield>
<asp:boundfield
sortexpression="FirstName"
datafield="FirstName"
headertext="FirstName">
<itemstyle forecolor="#C00000">
</itemstyle>
</asp:boundfield>
<asp:buttonfield
text="TestButton"
buttontype="Button">
</asp:buttonfield>
</fields>
</asp:detailsview>
</form>
</body>
</html>
Комментарии
ItemStyleСвойство управляет внешним видом любых текстовых данных, отображаемых типом, производным от DataControlField .The ItemStyle property governs the appearance of any text data displayed by a type derived from DataControlField. Например, при привязке BoundField элемента управления к текстовым данным можно использовать ItemStyle свойство для изменения внешнего вида отображаемого текста.For example, when you bind a BoundField control to text data, you can use the ItemStyle property to alter the appearance of the text that is displayed.