SqlDataSourceStatusEventHandler Delegate
Assembly: System.Web (in system.web.dll)
public delegate void SqlDataSourceStatusEventHandler ( Object^ sender, SqlDataSourceStatusEventArgs^ e )
/** @delegate */ public delegate void SqlDataSourceStatusEventHandler ( Object sender, SqlDataSourceStatusEventArgs e )
Not applicable.
Parameters
- sender
The source of the event, the SqlDataSource control.
- e
A SqlDataSourceStatusEventArgs that contains the event data.
When you create a SqlDataSourceStatusEventHandler delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see Consuming Events.
The following code example demonstrates how to handle the Updated event and examine the values contained in the SqlDataSourceStatusEventArgs object. The OnDSUpdatedHandler is called by the OnUpdated method to perform additional post-processing after an Update action is performed by a SqlDataSource control.
<%@Page Language="VJ#" %>
<%@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.get_AffectedRows() > 0) {
// Perform any additional processing, such as sending an e-mail notification.
Label1.set_Text(get_Request().get_LogonUserIdentity().get_Name() +
" changed user information successfully!");
}
else {
Label1.set_Text("No data updated!");
}
} //OnDSUpdatedHandler
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:SqlDataSource
id="SqlDataSource1"
runat="server"
DataSourceMode="DataSet"
ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
SelectCommand="SELECT EmployeeID,FirstName,LastName,Title FROM Employees"
UpdateCommand="Update Employees SET FirstName=@FirstName,LastName=@LastName,Title=@Title WHERE EmployeeID=@EmployeeID"
OnUpdated="OnDSUpdatedHandler">
</asp:SqlDataSource>
<asp:GridView
id="GridView1"
runat="server"
AutoGenerateColumns="False"
DataKeyNames="EmployeeID"
AutoGenerateEditButton="True"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField HeaderText="First Name" DataField="FirstName" />
<asp:BoundField HeaderText="Last Name" DataField="LastName" />
<asp:BoundField HeaderText="Title" DataField="Title" />
</Columns>
</asp:GridView>
<asp:Label
id="Label1"
runat="server">
</asp:Label>
</form>
</body>
</html>