DetailsView.InsertRowStyle Właściwość

Definicja

Pobiera odwołanie do TableItemStyle obiektu, który umożliwia ustawienie wyglądu wierszy danych w kontrolce DetailsView , gdy kontrolka DetailsView jest w trybie wstawiania.

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

Wartość właściwości

TableItemStyle

Odwołanie do TableItemStyle elementu reprezentującego styl wierszy danych w kontrolce DetailsView , gdy kontrolka DetailsView jest w trybie wstawiania.

Atrybuty

Przykłady

W poniższym przykładzie kodu pokazano, jak za pomocą InsertRowStyle właściwości określić ustawienia czcionki i stylu wierszy danych, gdy kontrolka DetailsView jest w trybie wstawiania.


<%@ 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>

Uwagi

Wiersze danych w kontrolce DetailsView są wyświetlane przy użyciu tego stylu, gdy kontrolka DetailsView jest w trybie wstawiania. InsertRowStyle Użyj właściwości , aby kontrolować wygląd wierszy danych w trybie wstawiania. Ta właściwość jest tylko do odczytu; można jednak ustawić właściwości zwracanego TableItemStyle obiektu. Właściwości można ustawić deklaratywnie w postaci Property-Subproperty, gdzie Subproperty jest właściwością TableItemStyle obiektu (na przykład InsertRowStyle-ForeColor). Właściwości można również ustawić programowo w formularzu Property.Subproperty (na przykład InsertRowStyle.ForeColor). Typowe ustawienia zwykle obejmują niestandardowy kolor tła, kolor pierwszego planu i właściwości czcionki.

Dotyczy

Zobacz też