DataControlField.ControlStyle Proprietà

Definizione

Ottiene lo stile di tutti i controlli server Web contenuti nell'oggetto 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; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.ControlStyle : System.Web.UI.WebControls.Style
Public ReadOnly Property ControlStyle As Style

Valore della proprietà

Style

Oggetto Style che determina l'aspetto dei controlli server Web contenuti nel campo.A Style that governs the appearance of Web server controls contained by the field.

Attributi

Esempio

Nell'esempio di codice seguente viene illustrato come BoundField utilizzare ButtonField gli oggetti e, derivati da DataControlField , per visualizzare le righe in un DetailsView controllo.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 proprietà dell' ButtonField oggetto viene impostata e determina il modo in cui LinkButton viene visualizzato il controllo contenuto nel campo.The 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>

Commenti

La ControlStyle Proprietà governa l'aspetto di tutti i controlli server Web contenuti in tipi derivati da DataControlField .The ControlStyle property governs the appearance of any Web server controls contained by types derived from DataControlField.

Questa proprietà non ha effetto su tutti i tipi derivati.This property does not affect all derived types. Il BoundField controllo, che in genere Visualizza i dati di testo e contiene solo TextBox controlli, è interessato dalla ControlStyle proprietà solo quando è in Edit stato.The BoundField control, which typically displays text data and contains only TextBox controls, is only affected by the ControlStyle property when in Edit state. I controlli server Web come ButtonField e CheckBoxField potrebbero essere interessati dalla ControlStyle proprietà, a seconda della configurazione specifica delle istanze dell'oggetto del controllo contenute nel 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. È ad esempio ButtonField possibile eseguire il rendering del controllo come LinkButton ImageButton oggetto, o Button .For example, the ButtonField control can be rendered as a LinkButton, ImageButton, or Button object. Anche se un LinkButton controllo è influenzato dagli font attributi dell' Style oggetto specificato, un Button controllo non lo è.Although a LinkButton control is affected by font attributes of the specified Style object, a Button control is not.

Si applica a

Vedi anche