Este artigo foi traduzido por máquina. Para visualizar o arquivo em inglês, marque a caixa de seleção Inglês. Você também pode exibir o texto Em inglês em uma janela pop-up, movendo o ponteiro do mouse sobre o texto.
Tradução
Inglês

DetailsViewPageEventHandler Representante

Represents the method that handles the PageIndexChanging event of a DetailsView control.

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

public delegate void DetailsViewPageEventHandler(
	Object sender,
	DetailsViewPageEventArgs e
)

Parâmetros

sender
Tipo: System.Object

A origem do evento.

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

A DetailsViewPageEventArgs that contains the event data.

The DetailsView control raises the PageIndexChanging event when a pager button (a button with its CommandName property set to "Page") within the control is clicked, but before the DetailsView control handles the paging operation.Isso permite que você forneça um manipulador de eventos que executa um Personalizar de rotina, como cancelar o operação de paginação, sempre que esse evento ocorre.

Observação:

Pager buttons are usually located in the pager row of a DetailsView control.

When you create a DetailsViewPageEventHandler delegate, you identify the method that will handle the event.To the evento with Your manipulador de eventos, associar adicionar an instância of the delegate to the evento.Is the manipulador de eventos chamado whenever the evento occurs, unless you remover the delegate.For more information about event-handler delegates, see Eventos e representantes.

The following code example demonstrates how to programmatically add a DetailsViewPageEventHandler delegate to the PageIndexChanging event of a DetailsView control.


<%@ Page language= %>

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

   Page_Load(Object sender, EventArgs e)
  {

    
    DetailsView customerDetailsView =  DetailsView();

    
    customerDetailsView.ID = ;
    customerDetailsView.DataSourceID = ;
    customerDetailsView.AutoGenerateRows = ;
    customerDetailsView.AutoGenerateEditButton = ;
    customerDetailsView.AllowPaging = ;
    customerDetailsView.DataKeyNames =  String[1] {  };
    customerDetailsView.PagerSettings.Position = PagerPosition.Bottom;

    
    
    customerDetailsView.PageIndexChanging +=  DetailsViewPageEventHandler(.CustomerDetailsView_PageIndexChanging);
    customerDetailsView.ModeChanging +=  DetailsViewModeEventHandler(.CustomerDetailsView_ModeChanging);

    
    
    DetailsViewPlaceHolder.Controls.Add(customerDetailsView);

  }

   CustomerDetailsView_PageIndexChanging(Object sender, DetailsViewPageEventArgs e)
  {
    
    
    DetailsView customerDetailsView = (DetailsView)sender;

    
    
     (customerDetailsView.CurrentMode == DetailsViewMode.Edit)
    {
      e.Cancel = ;

      
       newPage = e.NewPageIndex + 1;
      MessageLabel.Text =  + 
        newPage.ToString() + ;
    }
  }

   CustomerDetailsView_ModeChanging(Object sender, DetailsViewModeEventArgs e)
  {
    
    MessageLabel.Text = ;
  }

</script>

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

      <h3>DetailsViewPageEventHandler Example</h3>

        <!-- Use a PlaceHolder control  the container  the -->
        <!-- dynamically generated DetailsView control.         -->       
        <asp:placeholder id=
          runat=/>

        <br/><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="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"
          connectionstring=
           
          runat=/>

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



The following code example demonstrates how to declaratively add a DetailsViewPageEventHandler delegate to the PageIndexChanging event of a DetailsView control.


<%@ Page language= %>

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

   CustomerDetailsView_PageIndexChanging(Object sender, DetailsViewPageEventArgs e)
  {
    
    
     (CustomerDetailsView.CurrentMode == DetailsViewMode.Edit)
    {
      e.Cancel = ;

      
       newPage = e.NewPageIndex + 1;
      MessageLabel.Text =  + 
        newPage.ToString() + ;
    }
  }

   CustomerDetailsView_ModeChanging(Object sender, DetailsViewModeEventArgs e)
  {
    
    MessageLabel.Text = ;
  }

</script>

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

      <h3>DetailsViewPageEventHandler Example</h3>

        <asp:detailsview id=
          datasourceid=
          autogeneraterows=
          autogenerateeditbutton=
          datakeynames=  
          allowpaging=
          onpageindexchanging= 
          onmodechanging=
          runat=>

          <pagersettings position=/> 

        </asp:detailsview>

        <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="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"
          connectionstring=
           
          runat=/>

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



Mostrar: