SqlDataSource.Updated Event

Occurs when an update operation has completed.

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

public event SqlDataSourceStatusEventHandler Updated
<asp:SqlDataSource OnUpdated="SqlDataSourceStatusEventHandler" />

Handle the Updated event to examine the values of output parameters after an update operation has completed. The output parameters are available from the SqlDataSourceStatusEventArgs object that is associated with the event.

For more information about handling events, see Consuming Events.

The following code example demonstrates how to display and update data that is retrieved from an ODBC database in a GridView control. After a record is successfully updated, the Updated event is handled by an event handler to perform a post-processing step where an e-mail notification is sent.

<%@Page  Language="C#" %>
<%@Import Namespace="System.Web.Mail" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

 private void OnDSUpdatedHandler(Object source, SqlDataSourceStatusEventArgs e) {
    if (e.AffectedRows > 0) {
        // Perform any additional processing, such as sending an e-mail notification.
        Label1.Text = Request.LogonUserIdentity.Name +
            " changed user information sucessfully!";
    else {
        Label1.Text = "No data updated!";

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
    <!-- This example uses a Northwind database that is hosted by an ODBC-compliant
         database. To run this sample, create an ODBC DSN to any database that hosts
         the Northwind database, including Microsoft SQL Server or Microsoft Access,
         change the name of the DSN in the ConnectionString, and view the page.
    <form id="form1" runat="server">

          SelectCommand="SELECT EmployeeID,FirstName,LastName,Title FROM Employees"
          UpdateCommand="Update Employees SET FirstName=?,LastName=?,Title=? WHERE EmployeeID=?"

              <asp:BoundField HeaderText="First Name" DataField="FirstName" />
              <asp:BoundField HeaderText="Last Name" DataField="LastName" />
              <asp:BoundField HeaderText="Title" DataField="Title" />



.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

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.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft