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

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; }
member this.ControlStyle : System.Web.UI.WebControls.Style
Public ReadOnly Property ControlStyle As Style

Valore della proprietà

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.

Esempi

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

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 TextBox e contiene solo controlli, ControlStyle è interessato dalla proprietà solo Edit quando è in 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 CheckBoxField ButtonField controlliControlStyle server Web come e potrebbero essere interessati dalla 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 possibile ButtonField eseguire il rendering del controllo LinkButtoncome oggetto ImageButton, o Button .For example, the ButtonField control can be rendered as a LinkButton, ImageButton, or Button object. Anche se LinkButton un controllo è influenzato font dagli attributi dell'oggetto Style 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