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

GridViewUpdatedEventArgs Classe

Provides data for the RowUpdated event.

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

[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class GridViewUpdatedEventArgs : EventArgs

The GridView control raises the RowUpdated event when an Update button in the control is clicked, but after the GridView control updates the record.(An Update button is a button control whose CommandName property is set to "Update".) Você pode executar um Personalizar de rotina sempre que esse evento ocorre, como verificar os resultados de uma operação Atualizar.

A GridViewUpdatedEventArgs object is passed to the event handler, which enables you to determine the number of records that were affected and any exceptions that might have occurred.To determine the number of records that were affected by the update operation, use the AffectedRows property.To determine whether any exceptions occurred, use the Exception property.You can also indicate whether the exception was handled in the event handler by setting the ExceptionHandled property.

To access the key field values for the updated record, use the Keys property.You can access the original non-key field values by using the OldValues property.You can access the updated non-key field values by using the NewValues properties.

By default, the GridView control returns to read-only mode after an update operation.When you handle an exception that occurred during the update operation, you can keep the GridView control in edit mode by setting the KeepInEditMode property to true.

For more information about how to handle events, see Consumindo Eventos.

For a list of initial property values for an instance of the GridViewUpdatedEventArgs class, see the GridViewUpdatedEventArgs constructor.

O exemplo a seguir mostra como determinar se ocorreu uma exceção durante uma operação de Atualizar.


<%@ Page language= %>

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

   CustomersGridView_RowUpdated(Object sender, GridViewUpdatedEventArgs e)
  {
    
    
     (e.Exception == )
    {
      
      
      
      
       (e.AffectedRows == 1)
      {
        
        String keyFieldValue = e.Keys[].ToString();

        
        Message.Text =  + keyFieldValue +
          ;

        
        DisplayValues((OrderedDictionary)e.NewValues, (OrderedDictionary)e.OldValues);
      }
      
      {
        
        Message.Text = ;

        
        
        e.KeepInEditMode = ;
      }
    }
    
    {
      
      Message.Text = e.Exception.Message;

      
      
      e.ExceptionHandled = ;

      e.KeepInEditMode = ;
    }
  }

   DisplayValues(OrderedDictionary newValues, OrderedDictionary oldValues)
  {

    Message.Text += ;

    
    
     ( i = 0; i < oldValues.Count; i++)
    {
      Message.Text +=  + oldValues[i].ToString() +
         + newValues[i].ToString() + ;
    }

    Message.Text += ;

  }

</script>

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

      <h3>GridViewUpdatedEventArgs 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=
        autogenerateeditbutton=
        allowpaging= 
        datakeynames=
        onrowupdated= 
        runat=>
      </asp:gridview>

      <br/>

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

      <!-- 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>



System.EventArgs
  System.Object
    System.Web.UI.WebControls.GridViewUpdatedEventArgs

Quaisquer membros públicos estático (compartilhados na Visual Basic) desse tipo são Thread seguro. Não há garantia de que qualquer membro de instância seja isento de segmentos.

Contribuições da comunidade

ADICIONAR
Mostrar:
© 2015 Microsoft