GridView.EditRowStyle Właściwość

Definicja

Pobiera odwołanie do TableItemStyle obiektu, który umożliwia ustawienie wyglądu wiersza wybranego do edycji w kontrolce GridView .

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

Wartość właściwości

Odwołanie do TableItemStyle elementu reprezentującego styl wiersza edytowanego w kontrolce GridView .

Atrybuty

Przykłady

W poniższym przykładzie pokazano, jak używać EditRowStyle właściwości do definiowania stylu niestandardowego dla wiersza edytowanego w kontrolce GridView .


<%@ 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>GridView EditRowStyle Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView EditRowStyle Example</h3>

      <!-- The GridView control automatically sets the columns     -->
      <!-- specified in the datakeynames property as read-only.    -->
      <!-- No input controls are rendered for these columns in     -->
      <!-- edit mode.                                              -->
      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="true"
        autogeneratedeletebutton="true"
        autogenerateeditbutton="true"
        datakeynames="CustomerID"  
        runat="server">
        
        <editrowstyle backcolor="LightCyan"
          forecolor="DarkBlue"/>
                    
      </asp:gridview>
            
      <!-- 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="CustomersSqlDataSource"  
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
        updatecommand="Update Customers SET CompanyName=@CompanyName, Address=@Address, City=@City, PostalCode=@PostalCode, Country=@Country WHERE (CustomerID = @CustomerID)"
        deletecommand="Delete from Customers where CustomerID = @CustomerID"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </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>GridView EditRowStyle Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView EditRowStyle Example</h3>

      <!-- The GridView control automatically sets the columns     -->
      <!-- specified in the datakeynames property as read-only.    -->
      <!-- No input controls are rendered for these columns in     -->
      <!-- edit mode.                                              -->
      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="true"
        autogeneratedeletebutton="true"
        autogenerateeditbutton="true"
        datakeynames="CustomerID"  
        runat="server">
        
        <editrowstyle backcolor="LightCyan"
          forecolor="DarkBlue"/>
                    
      </asp:gridview>
            
      <!-- 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="CustomersSqlDataSource"  
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
        updatecommand="Update Customers SET CompanyName=@CompanyName, Address=@Address, City=@City, PostalCode=@PostalCode, Country=@Country WHERE (CustomerID = @CustomerID)"
        deletecommand="Delete from Customers where CustomerID = @CustomerID"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

Uwagi

EditRowStyle Użyj właściwości , aby kontrolować wygląd wiersza edytowanego w kontrolceGridView. 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 przy użyciu jednej z następujących metod:

  • Umieść atrybut w tagu otwierającym kontrolki GridView w formularzu Property-Subproperty, gdzie Subproperty jest właściwością TableItemStyle obiektu (na przykład EditRowStyle-ForeColor).

  • Zagnieżdżanie <EditRowStyle> elementu między tagami otwierania i zamykania kontrolki GridView .

Właściwości można również ustawić programowo w formularzu Property.Subproperty (na przykład EditRowStyle.ForeColor). Typowe ustawienia zwykle obejmują niestandardowy kolor tła, kolor pierwszego planu i właściwości czcionki.

Dotyczy

Zobacz też