GridView.EditRowStyle GridView.EditRowStyle GridView.EditRowStyle GridView.EditRowStyle Property

Definición

Obtiene una referencia al objeto TableItemStyle que permite establecer la apariencia de la fila seleccionada para ser editada en un control GridView.Gets a reference to the TableItemStyle object that enables you to set the appearance of the row selected for editing in a GridView control.

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; }
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.A reference to the TableItemStyle that represents the style of the row being edited in a GridView control.

Ejemplos

En el ejemplo siguiente se muestra cómo utilizar EditRowStyle la propiedad para definir un estilo personalizado para la fila que se está GridView editando en un control.The following example demonstrates how to use the EditRowStyle property to define a custom style for the row being edited in a 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 el aspecto de la fila que se está editando en un GridView control.Use the EditRowStyle property to control the appearance of the row being edited in a GridView control. Esta propiedad es de solo lectura; sin embargo, puede establecer las propiedades del TableItemStyle objeto que devuelve.This property is read-only; however, you can set the properties of the TableItemStyle object it returns. Las propiedades se pueden establecer mediante declaración con uno de los métodos siguientes:The properties can be set declaratively using one of the following methods:

  • Coloque un atributo en la etiqueta de apertura del GridView control en el formulario Property-Subproperty, donde Subproperty es una propiedad del TableItemStyle objeto (por ejemplo, EditRowStyle-ForeColor).Place an attribute in the opening tag of the GridView control in the form Property-Subproperty, where Subproperty is a property of the TableItemStyle object (for example, EditRowStyle-ForeColor).

  • Anide un <EditRowStyle> elemento entre las etiquetas GridView de apertura y cierre del control.Nest an <EditRowStyle> element between the opening and closing tags of the GridView control.

Las propiedades también se pueden establecer mediante programación en el formulario Property.Subproperty (por ejemplo, EditRowStyle.ForeColor).The properties can also be set programmatically in the form Property.Subproperty (for example, EditRowStyle.ForeColor). La configuración común suele incluir un color de fondo personalizado, un color de primer plano y propiedades de fuente.Common settings usually include a custom background color, foreground color, and font properties.

Se aplica a

Consulte también: