Export (0) Print
Expand All

ObjectDataSource.Selected Event

Occurs when a Select operation has completed.

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

member Selected : IEvent<ObjectDataSourceStatusEventHandler,
    ObjectDataSourceStatusEventArgs>

Handle the Selected event to examine the values of a return value or output parameters, or to determine whether an exception was thrown after a Select operation has completed. The return value, output parameters, and exception handling properties are available from the ObjectDataSourceStatusEventArgs object that is associated with the event.

For more information about handling events, see Consuming Events.

The following three examples show a Web page, a code-behind page class, and a data-access class that enable a user to retrieve and update records in the Employees table in the Northwind database.

The first example shows a Web page that contains two ObjectDataSource controls, a DropDownList control, and a DetailsView control. The first ObjectDataSource control and the DropDownList control are used to retrieve and display employee names from the database. The second ObjectDataSource control and the DetailsView control are used to retrieve, display, and modify the data from the employee record that is selected by the user.

No code example is currently available or this language may not be supported.

The second example shows handlers for the Selected and Updating events. The Selected event handler serializes the object that contains data that was retrieved from the Employee table. The serialized object is stored in view state. The Updating event handler deserializes the object in view state that contains the original data for the data record that is being updated. The object that contains the original data is passed as a parameter to the Update method. The original data must be passed to the database so that it can be used to check whether the data has been modified by another process.

No code example is currently available or this language may not be supported.

The third example shows the data access class that interacts with the Northwind database. The class uses LINQ to query and update the Employees table. The example requires a LINQ to SQL class that represents the Northwind database and Employees table. For more information, see How to: Create LINQ to SQL Classes in a Web Project.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0
Show:
© 2015 Microsoft