DataControlField.ControlStyle DataControlField.ControlStyle DataControlField.ControlStyle DataControlField.ControlStyle Property

Definición

Obtiene el estilo de cualquier control de servidor web contenido en el objeto DataControlField.Gets the style of any Web server controls contained by the DataControlField object.

public:
 property System::Web::UI::WebControls::Style ^ ControlStyle { System::Web::UI::WebControls::Style ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.Style ControlStyle { get; }
member this.ControlStyle : System.Web.UI.WebControls.Style
Public ReadOnly Property ControlStyle As Style

Valor de propiedad

Un objeto Style que define el aspecto de los controles de servidor Web que contiene el campo.A Style that governs the appearance of Web server controls contained by the field.

Ejemplos

En el ejemplo de código siguiente se muestra BoundField cómo ButtonField utilizar los objetos y, que DataControlFieldse derivan de, para DetailsView mostrar las filas de un control.The following code example demonstrates how to use BoundField and ButtonField objects, which are derived from DataControlField, to display rows in a DetailsView control. La ControlStyle propiedad LinkButton del objeto se establece y rige cómo se muestra el control contenido en el campo. ButtonFieldThe ControlStyle property of the ButtonField object is set and governs how the LinkButton control contained by the field is displayed.

<%@ 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: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="<%$ ConnectionStrings:MyNorthwind%>">
    </asp:sqldatasource>

  </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: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="<%$ ConnectionStrings:MyNorthwind%>">
    </asp:sqldatasource>

  </form>
</body>
</html>

Comentarios

La ControlStyle propiedad rige la apariencia de todos los controles de servidor web contenidos en los tipos DataControlFieldderivados de.The ControlStyle property governs the appearance of any Web server controls contained by types derived from DataControlField.

Esta propiedad no afecta a todos los tipos derivados.This property does not affect all derived types. El BoundField control, que normalmente muestra los datos de texto y TextBox solo contiene controles, solo se ve ControlStyle afectado por la Edit propiedad cuando está en el estado.The BoundField control, which typically displays text data and contains only TextBox controls, is only affected by the ControlStyle property when in Edit state. Los controles de servidor Web ButtonField como CheckBoxField y pueden verse afectados por ControlStyle la propiedad, dependiendo de la configuración específica de las instancias de objeto de control que contiene el campo.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. Por ejemplo, el ButtonField control se puede representar como un LinkButtonobjeto, ImageButtono Button .For example, the ButtonField control can be rendered as a LinkButton, ImageButton, or Button object. Aunque un LinkButton control se ve afectado font por los atributos del Style objeto especificado, Button un control no es.Although a LinkButton control is affected by font attributes of the specified Style object, a Button control is not.

Se aplica a

Consulte también: