DataControlField.ControlStyle Property
Assembly: System.Web (in system.web.dll)
The ControlStyle property governs the appearance of any Web server controls contained by types derived from DataControlField.
This property does not affect all derived types. The BoundField control, which typically displays text data and contains only TextBox controls, is only affected by the ControlStyle property when in Edit state. Web server controls such as ButtonField and CheckBoxField might be affected by the ControlStyle property, depending on the specific configuration of the control object instances contained by the field. For example, the ButtonField control can be rendered as a LinkButton, ImageButton, or Button object. Although a LinkButton control is affected by font attributes of the specified Style object, a Button control is not.
The following code example demonstrates how to use BoundField and ButtonField objects, which are derived from DataControlField, to display rows in a DetailsView control. The ControlStyle property of the ButtonField object is set and governs how the LinkButton control contained by the field is displayed.
<%@ page language="VJ#" %>
<html>
<body>
<form runat="server">
<asp:detailsview
id="DetailsView1"
runat="server"
allowpaging="True"
datasourceid="SqlDataSource1"
autogeneraterows="False"
width="312px"
height="152px">
<fields>
<asp:boundfield
visible="False"
sortexpression="EmployeeID"
datafield="EmployeeID">
</asp:boundfield>
<asp:boundfield
sortexpression="LastName"
datafield="LastName"
headertext="LastName">
</asp:boundfield>
<asp:boundfield
sortexpression="FirstName"
datafield="FirstName"
headertext="FirstName">
</asp:boundfield>
<asp:boundfield
sortexpression="Title"
datafield="Title"
headertext="Title">
</asp:boundfield>
<asp:buttonfield text="Button">
<controlstyle font-bold="True" forecolor="Red" />
</asp:buttonfield>
</fields>
</asp:detailsview>
<asp:sqldatasource
id="SqlDataSource1"
runat="server"
selectcommand="Select * From Employees"
connectionstring="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind">
</asp:sqldatasource>
</form>
</body>
</html>
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.