DetailsView.InsertRowStyle Proprietà

Definizione

Ottiene un riferimento all'oggetto TableItemStyle che consente di impostare l'aspetto delle righe di dati in un controllo DetailsView quando il controllo DetailsView è in modalità di inserimento.

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

Valore della proprietà

Riferimento all'oggetto TableItemStyle che rappresenta lo stile delle righe di dati in un controllo DetailsView quando il controllo DetailsView è in modalità di inserimento.

Attributi

Esempio

Nell'esempio di codice seguente viene illustrato come usare la InsertRowStyle proprietà per specificare le impostazioni di carattere e stile per le righe di dati quando il DetailsView controllo è in modalità di inserimento.


<%@ 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>DetailsView InsertRowStyle Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView InsertRowStyle Example</h3>
                
        <asp:detailsview id="CustomerDetailView"
          datasourceid="DetailsViewSource"
          datakeynames="CustomerID"
          autogenerateinsertbutton="true"  
          autogeneraterows="true"
          allowpaging="true"  
          runat="server">
               
          <fieldheaderstyle backcolor="Navy"
            forecolor="White"/>
            
          <insertrowstyle backcolor="Yellow"/>
                    
        </asp:detailsview>
        
        <!-- This example uses Microsoft SQL Server and connects  -->
        <!-- to the Northwind sample database. Use an ASP.NET     -->
        <!-- expression to retrieve the connection string value   -->
        <!-- from the web.config file.                            -->
        <asp:SqlDataSource ID="DetailsViewSource" runat="server" 
          ConnectionString=
            "<%$ ConnectionStrings:NorthWindConnectionString%>"
            InsertCommand="INSERT INTO [Customers]([CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country]) VALUES (@CustomerID, @CompanyName, @Address, @City, @PostalCode, @Country)"
          SelectCommand="Select [CustomerID], [CompanyName], 
            [Address], [City], [PostalCode], [Country] From 
            [Customers]">
        </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>DetailsView InsertRowStyle Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView InsertRowStyle Example</h3>
                
        <asp:detailsview id="CustomerDetailView"
          datasourceid="DetailsViewSource"
          datakeynames="CustomerID"
          autogenerateinsertbutton="true"  
          autogeneraterows="true"
          allowpaging="true"  
          runat="server">
               
          <fieldheaderstyle backcolor="Navy"
            forecolor="White"/>
            
          <insertrowstyle backcolor="Yellow"/>
                    
        </asp:detailsview>
        
        <!-- This example uses Microsoft SQL Server and connects  -->
        <!-- to the Northwind sample database. Use an ASP.NET     -->
        <!-- expression to retrieve the connection string value   -->
        <!-- from the web.config file.                            -->
        <asp:SqlDataSource ID="DetailsViewSource" runat="server" 
          ConnectionString=
            "<%$ ConnectionStrings:NorthWindConnectionString%>"
            InsertCommand="INSERT INTO [Customers]([CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country]) VALUES (@CustomerID, @CompanyName, @Address, @City, @PostalCode, @Country)"
          SelectCommand="Select [CustomerID], [CompanyName], 
            [Address], [City], [PostalCode], [Country] From 
            [Customers]">
        </asp:SqlDataSource>
    </form>
  </body>
</html>

Commenti

Le righe di dati nel DetailsView controllo vengono visualizzate usando questo stile quando il DetailsView controllo è in modalità di inserimento. Utilizzare la InsertRowStyle proprietà per controllare l'aspetto delle righe di dati in modalità inserimento. Questa proprietà è di sola lettura; tuttavia, è possibile impostare le proprietà dell'oggetto TableItemStyle restituito. Le proprietà possono essere impostate in modo dichiarativo nel formato Property-Subproperty, dove Subproperty è una proprietà dell'oggetto TableItemStyle , ad esempio InsertRowStyle-ForeColor. Le proprietà possono anche essere impostate a livello di codice nel modulo Property.Subproperty ( ad esempio , InsertRowStyle.ForeColor). Le impostazioni comuni in genere includono un colore di sfondo personalizzato, il colore di primo piano e le proprietà del carattere.

Si applica a

Vedi anche