Este artigo foi traduzido por máquina. Coloque o ponteiro do mouse sobre as frases do artigo para ver o texto original. Mais informações.
Tradução
Original
Este tópico ainda não foi avaliado como - Avalie este tópico

GridView.AutoGenerateEditButton Propriedade

Gets or sets a value indicating whether a CommandField field column with an Edit button for each data row is automatically added to a GridView control.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (em System.Web. dll)

public virtual bool AutoGenerateEditButton { get; set; }

Valor da propriedade

Tipo: System.Boolean

true to automatically add a CommandField field column with an Edit button for each data row; otherwise, false.The default is false.

When a data source control that supports updating is bound to a GridView control, the GridView control can take advantage of the data source control's capabilities and provide automatic updating functionality.

Observação:

Para um Fonte de Dados Controlarar para dados Atualizar, ele deve ser configurado para dados Atualizar.Para configurar um Fonte de Dados Controlarar Atualizar registros, consulte a documentação para a específicas Fonte de Dados Controlarar.

When the AutoGenerateEditButton property is set to true, a column (represented by a CommandField object) with an Edit button for each data row is automatically added to the GridView control.Clicar um botão Editar para uma linha coloca essa linha no modo de edição.When a row is in edit mode, each column field in the row that is not read-only displays the appropriate input control, such as a TextBox control, for the field's data type.Isso permite que o usuário modificar o valor do campo.

Quando clicado, o botão Editar também é substituído com um botão de Atualizar e um botão ' Cancelar '.Clicar o botão Atualizar Atualiza a linha Na Fonte de Dados com qualquer valor altera e retorna a linha para modo de exibição.Clicando no botão ' Cancelar ' abandons alterações valor e retorna a linha para exibir o modo.

Observação:

You can programmatically put a row in edit mode by setting the EditIndex property with the index of the row.To programmatically exit edit mode, set the EditIndex property to -1.

When using the built-in updating functionality, you must set the DataKeyNames property with a comma-separated list of field names to identify the primary key field or fields of the data source; otherwise, the built-in updating functionality will not be able to update the correct record.When using automatically generated field columns (by setting the AutoGenerateColumns property to true), the GridView control automatically ensures that the automatically generated field columns that correspond to the field or fields specified in the DataKeyNames property are read-only.

You can control the appearance of a row that is in edit mode by using the EditRowStyle property.Configurações comuns geralmente incluem um Personalizar Cor do plano de fundo, primeiro plano cor e fonte propriedades.

The GridView control provides several events that you can use to perform a custom action when a row is updated.A tabela a seguir lista os eventos disponíveis.

Evento

Descrição

RowCancelingEdit

Occurs when a row's Cancel button is clicked, but before the GridView control cancels out of edit mode.Este evento é freqüentemente usado para parar a operação cancelando.

RowEditing

Occurs when a row's Edit button is clicked, but before the GridView control enters edit mode.Este evento é freqüentemente usado para cancelar a operação de edição.

RowUpdated

Occurs when a row's Update button is clicked, but after the GridView control updates the row.Este evento é freqüentemente usado para verificar os resultados da operação de atualização.

RowUpdating

Occurs when a row's Update button is clicked, but before the GridView control updates the row.Este evento é freqüentemente usado para cancelar a operação de atualização.

The following code example demonstrates how to use the AutoGenerateEditButton property to enable the automatic editing feature of the GridView control.


<%@ Page language= %>

<!DOCTYPE html PUBLIC "-
    "http:
<html xmlns="http:
  <head runat=>
    <title>GridView Edit Example</title>
</head>
<body>
    <form id= runat=>

      <h3>GridView Edit Example</h3>

      <!-- The GridView control automatically sets the columns     -->
      <!-- specified  the datakeynames property  read-only.    -->
      <!-- No input controls are rendered  these columns      -->
      <!-- edit mode.                                              -->
      <asp:gridview id= 
        datasourceid= 
        autogeneratecolumns=
        autogeneratedeletebutton=
        autogenerateeditbutton=
        datakeynames=  
        runat=>
      </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   -->
      <!--  the Web.config file.                            -->
      <asp:sqldatasource id=  
        selectcommand=
        updatecommand=
        deletecommand=
        connectionstring=
        runat=>
      </asp:sqldatasource>

    </form>
  </body>
</html>



Isso foi útil para você?
(1500 caracteres restantes)

Contribuições da comunidade

ADICIONAR
A Microsoft está realizando uma pesquisa online para saber sua opinião sobre o site do MSDN. Se você optar por participar, a pesquisa online lhe será apresentada quando você sair do site do MSDN.

Deseja participar?
© 2013 Microsoft. Todos os direitos reservados.