Exportar (0) Imprimir
Expandir Tudo
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

GridView.RowCancelingEdit Evento

Ocorre quando o botão ' Cancelar ' de uma linha na Modo de Edição é clicado, mas antes de linha sai Modo de Edição.

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

public event GridViewCancelEditEventHandler RowCancelingEdit

The RowCancelingEdit event is raised when the Cancel button of a row in edit mode is clicked, but before the row exits edit mode.This allows you to provide an event-Manipulação método that Performs a Personalizar Routine, such as Stopping the Cancelar operação if it would pôr the linha in an estado undesired, whenever this evento occurs.

A GridViewCancelEditEventArgs object is passed to the event-handling method, which allows you to determine the index of the current row and to indicate that the cancel operation should be stopped.To stop the cancel operation, set the Cancel property of the GridViewCancelEditEventArgs object to true.

Para obter mais informações sobre tratamento de eventos, consulte Consumindo Eventos.

The following code example demonstrates how to use the RowCancelingEdit event to display a cancellation message when the user cancels the update operation of a GridView control.


<%@ Page language= %>

<!DOCTYPE html PUBLIC "-
    "http:
<script runat=>

   CustomersGridView_RowCancelingEdit(Object sender, GridViewCancelEditEventArgs e)
  {

    
    
    GridViewRow row = CustomersGridView.Rows[e.RowIndex];

    
    
    
    
    
    Message.Text =  + row.Cells[1].Text + ; 

  }

   CustomersGridView_RowEditing(Object sender, GridViewEditEventArgs e)
  {

    
    Message.Text = ;

  }

   CustomersGridView_RowUpdated(Object sender, GridViewUpdatedEventArgs e)
  {

    
    Message.Text = ;

  }

</script>

<html xmlns="http:
  <head runat=>
    <title>GridView RowCancelingEdit Example</title>
</head>
<body>
    <form id= runat=>

      <h3>GridView RowCancelingEdit Example</h3>

      <asp:label id=
        forecolor=
        runat=/>

      <br/>

      <!-- The GridView control automatically sets the columns     -->
      <!-- specified  the datakeynames attribute  read-only.   -->
      <!-- No input controls are rendered  these columns      -->
      <!-- edit mode.                                              -->
      <asp:gridview id= 
        datasourceid= 
        autogeneratecolumns=
        autogenerateeditbutton=
        allowpaging= 
        datakeynames=
        onrowcancelingedit=
        onrowediting= 
        onrowupdated=    
        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=
        connectionstring=
        runat=>
      </asp:sqldatasource>

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



Contribuições da comunidade

ADICIONAR
Mostrar:
© 2014 Microsoft