SqlDataSource::Updating Event

 

Occurs before an update operation.

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

public:
event SqlDataSourceCommandEventHandler^ Updating {
	void add(SqlDataSourceCommandEventHandler^ value);
	void remove(SqlDataSourceCommandEventHandler^ value);
}

Handle the Updating event to perform additional initialization operations that are specific to your application, to validate the values of parameters, or to change the parameter values before the SqlDataSource control performs the update operation. The connection to the underlying data source is not yet open when the event handler delegate is called. Therefore, you cannot directly cancel the Update database operation by calling the Cancel method on the DbCommand object that is exposed by the SqlDataSourceCommandEventArgs object. You can, however, cancel the database operation by setting the Cancel property of the SqlDataSourceCommandEventArgs to true.

For more information about handling events, see NIB: Consuming Events.

System_CAPS_security Security Note

Values are inserted into parameters without validation, which is a potential security threat. Use the Updating event to validate parameter values before executing the query. For more information, see Script Exploits Overview.

The following code example demonstrates how to display data that is retrieved from a Microsoft SQL Server database in a DropDownList control and update the record using a TextBox control. The example shows how you can use a DbTransaction object to add transaction context when using the SqlDataSource control to update data.

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

.NET Framework
Available since 2.0
Return to top
Show: