GridView.EditRowStyle Propiedad

Definición

Obtiene una referencia al objeto TableItemStyle que permite establecer la apariencia de la fila seleccionada para ser editada en un control 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

Valor de propiedad

Referencia a TableItemStyle que representa el estilo de la fila que se va a editar en un control GridView.

Atributos

Ejemplos

En el ejemplo siguiente se muestra cómo usar la EditRowStyle propiedad para definir un estilo personalizado para la fila que se está editando en un GridView control .


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

Comentarios

Utilice la EditRowStyle propiedad para controlar la apariencia de la fila que se está editando en un GridView control . Esta propiedad es de solo lectura; sin embargo, puede establecer las propiedades del TableItemStyle objeto que devuelve. Las propiedades se pueden establecer mediante declaración mediante uno de los métodos siguientes:

  • Coloque un atributo en la etiqueta de apertura del GridView control con el formato Property-Subproperty, donde Subproperty es una propiedad del TableItemStyle objeto (por ejemplo, EditRowStyle-ForeColor).

  • Anida un <EditRowStyle> elemento entre las etiquetas de apertura y cierre del GridView control.

Las propiedades también se pueden establecer mediante programación en el formulario Property.Subproperty (por ejemplo, EditRowStyle.ForeColor). La configuración común suele incluir un color de fondo personalizado, un color de primer plano y propiedades de fuente.

Se aplica a

Consulte también