Export (0) Print
Expand All

EntityDataSource.Selected Event

Occurs after a query has been executed.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web.Entity (in System.Web.Entity.dll)

public event EventHandler<EntityDataSourceSelectedEventArgs> Selected
<asp:EntityDataSource OnSelected="EventHandler" />

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.

.NET Framework

Supported in: 4.5, 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft