Expandir Minimizar
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
1 de 1 pessoas classificaram isso como útil - Avalie este tópico

GridViewCancelEditEventHandler Representante

Represents the method that handles the RowCancelingEdit event of a GridView control.

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

public delegate void GridViewCancelEditEventHandler(
	Object sender,
	GridViewCancelEditEventArgs e
)

Parâmetros

sender
Tipo: System.Object

A origem do evento.

e
Tipo: System.Web.UI.WebControls.GridViewCancelEditEventArgs

A GridViewCancelEditEventArgs object that contains the event data.

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.

When you create a GridViewCancelEditEventHandler delegate, you identify the method that will handle the event.Para associar o evento com o manipulador de eventos, adicione uma instância do delegate ao evento.O manipulador de evento é chamado sempre que o evento ocorre, a menos que você remova o delegate.Para obter mais informações sobre delegates de manipulador de eventos, consulte Eventos e representantes.

The following example demonstrates how to programmatically add a GridViewCancelEditEventHandler delegate to the RowCancelingEdit event of a GridView control.


<%@ Page language= %>

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

   Page_Load(Object sender, EventArgs e)
  {

    
    GridView customerGridView =  GridView();

    
    customerGridView.ID = ;
    customerGridView.DataSourceID = ;
    customerGridView.AutoGenerateColumns = ;
    customerGridView.AutoGenerateEditButton = ;
    customerGridView.DataKeyNames =  String[] {  };

    
    customerGridView.RowCancelingEdit +=  GridViewCancelEditEventHandler(.CustomersGridView_RowCancelingEdit);
    customerGridView.RowUpdated +=  GridViewUpdatedEventHandler(.CustomersGridView_RowUpdated);

    
    
    GridViewPlaceHolder.Controls.Add(customerGridView);

  }

   CustomersGridView_RowCancelingEdit(Object sender, GridViewCancelEditEventArgs e)
  {

    
    Message.Text =  + e.RowIndex.ToString() + ; 

  }

   CustomersGridView_RowUpdated(Object sender, GridViewUpdatedEventArgs e)
  {

    
    Message.Text = ;

  }

</script>

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

      <h3>GridViewCancelEditEventHandler Example</h3>

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

      <br/>

      <asp:placeholder id=
        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>



The following example demonstrates how to declaratively add a GridViewCancelEditEventHandler delegate to the RowCancelingEdit event 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>



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

Contribuições da comunidade

ADICIONAR
© 2013 Microsoft. Todos os direitos reservados.