DataControlField.ItemStyle DataControlField.ItemStyle DataControlField.ItemStyle DataControlField.ItemStyle Property

Definizione

Ottiene lo stile di tutti i contenuti basati sul testo visualizzati da un campo di controllo dati.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; }
member this.ItemStyle : System.Web.UI.WebControls.TableItemStyle
Public ReadOnly Property ItemStyle As TableItemStyle

Valore della proprietà

Oggetto TableItemStyle che determina l'aspetto del testo visualizzato in un oggetto DataControlField.A TableItemStyle that governs the appearance of text displayed in a DataControlField.

Esempi

Nell'esempio di codice seguente viene illustrato come impostare in modo ItemStyle dichiarativo BoundField la proprietà sugli oggetti FirstName utilizzati LastName per visualizzare i DetailsView dati e in un controllo.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. Il DetailsView controllo ha la AutoGenerateRows proprietà impostata su false, che consente di visualizzare SelectCommand un subset dei dati restituiti dalla proprietà.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>

Commenti

La ItemStyle proprietà governa l'aspetto di tutti i dati di testo visualizzati da un tipo derivato DataControlFieldda.The ItemStyle property governs the appearance of any text data displayed by a type derived from DataControlField. Ad esempio, quando si associa un BoundField controllo ai dati di testo, è possibile usare ItemStyle la proprietà per modificare l'aspetto del testo visualizzato.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.

Si applica a

Vedi anche