Editare

Partajați prin


EntityDataSource.Selected Event

Definition

Occurs after a query has been executed.

public:
 event EventHandler<System::Web::UI::WebControls::EntityDataSourceSelectedEventArgs ^> ^ Selected;
public event EventHandler<System.Web.UI.WebControls.EntityDataSourceSelectedEventArgs> Selected;
member this.Selected : EventHandler<System.Web.UI.WebControls.EntityDataSourceSelectedEventArgs> 
Public Custom Event Selected As EventHandler(Of EntityDataSourceSelectedEventArgs) 

Event Type

Remarks

The Selected event is raised after a query has been executed and data has been returned. It is also raised if an error occurred during query preparation or execution.

The Results property of the EntityDataSourceSelectedEventArgs object contains an IEnumerable of objects that are returned from the query. Handle the Selected event to retrieve and store returned entities in the ViewState. Do this to persist object changes on the page.

The TotalRowCount property of the EntityDataSourceSelectedEventArgs object shows the total number of objects in all pages, regardless of the values passed by the data-bound control for paging. TotalRowCount is only retrieved if the data-bound control needs it, such as if paging is enabled.

If an error occurs when the query is prepared or executed, the Selected event is raised, the Exception property of the EntityDataSourceSelectedEventArgs object is set to the returned Exception, and the Results property is set to null. If you handle the exception in the Selected event handler, set the ExceptionHandled property to true. This prevents the exception from being raised again. When you specify a value of false for the ExceptionHandled property, the EntityDataSource re-raises the exception.

Applies to