DataControlField.ItemStyle Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Property Value
A TableItemStyle that governs the appearance of text displayed in a DataControlField.
- Attributes
Examples
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. 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>
Remarks
The ItemStyle property governs the appearance of any text data displayed by a type derived from DataControlField. 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.
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기