Assembly: System.Web (in System.Web.dll)
The business object is assumed to update data one record at a time, rather than in a batch.
Before the operation is performed, the OnUpdating method is called to raise the Updating event. You can handle the Updating event to examine the values of the parameters and to perform any preprocessing before an operation. To perform an update operation, the ObjectDataSourceView object uses reflection to create an instance of the object that is identified by the TypeName property. It then calls the method that is identified by the UpdateMethod property, using any associated UpdateParameters properties. After the operation completes, the OnUpdated method is called to raise the Updated event. You can handle the Updated event to examine any return values, output parameters, and exceptions, and to perform any post-processing.
For more information about parameter merging, object lifetime, and method resolution, see UpdateMethod.
You should validate any parameter value that you receive from the client. The runtime simply substitutes the parameter value into the UpdateMethod property.
This section contains two code examples. The first code example demonstrates how to use a DropDownList control, TextBox controls, and several ObjectDataSource objects to update data. The second code example shows the EmployeeLogic class that is used in the first code example.
The following code example demonstrates how to use a DropDownList control, TextBox controls, and several ObjectDataSource controls to update data. The DropDownList displays the name of a Northwind employee, while the TextBox controls are used to enter and update address information. Because the UpdateParameters collection contains a ControlParameter object that is bound to the selected value of the DropDownList, the button that raises the operation is enabled only after an employee is selected.
This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.
The following code example shows the EmployeeLogic class that is used in the preceding code example.