asp.net.ph

FormView.PageIndexChanging Event

System.Web.UI.WebControls Namespace   FormView Class


.NET Framework version 2.0

Occurs when any of the pager buttons in a FormView control is clicked, but before the page changes.

[ VB ]
Public Event PageIndexChanging As FormViewPageEventHandler

[ C# ]
public event FormViewPageEventHandler PageIndexChanging;

[ C++ ]
public: __event FormViewPageEventHandler* PageIndexChanging;

In [ JScript ], you can handle the events defined by a class, but you cannot define your own.

Remarks

The PageIndexChanging event is raised whenever any of the buttons in the page selection element of a FormView control is clicked, but before the FormView handles the paging operation.

This allows you to provide an event-handling method that performs a custom routine, such as canceling the paging operation, whenever this event occurs.

NOTE: This event is not raised when the PageIndex property is set programmatically.

Event Data

The method assigned to handle the event is passed an argument of type FormViewPageEventArgs object containing data related to this event. The following FormViewPageEventArgs properties provide information specific to this event.

Property Description
Cancel Gets or sets a value indicating whether the event should be canceled ( inherited from CancelEventArgs )
NewPageIndex Gets the index of the page selected by the user in the page selection element of the FormView control.

Example

The following example demonstrates how to use the PageIndexChanging event to cancel a paging operation.

<script runat = "server">

   void EmployeeFormView_PageIndexChanging ( Object src, FormViewPageEventArgs e ) {
      // Cancel the paging operation if the FormView control is in edit mode.
      if ( EmployeeFormView.CurrentMode == FormViewMode.Edit ) {
         e.Cancel = true;
         // Display an error message.
         int newPage = e.NewPageIndex + 1;
         MessageLabel.Text = "Please update the current record before moving to page " + 
            newPage.ToString ( ) + ".";
      }
   }

   void EmployeeFormView_ModeChanged ( Object src, EventArgs e ) {
      // Clear the message label.
      MessageLabel.Text = "";
   }

</script>
  C# VB

See Also

FormView Members   AllowPaging   FormViewPageEventArgs   FormViewPageEventHandler   Specifying Paging Behavior in a FormView Control Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph