SqlDataSource Updated Event
SqlDataSourceStatusEventArgsExample.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void SqlDataSource1_Updated(object sender, SqlDataSourceStatusEventArgs e)
{
if (e.AffectedRows > 0) {
Label1.Text = e.AffectedRows.ToString() + " row(s) updated successfully!";
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>asp.net OnUpdated, SqlDataSourceStatusEventArgs example: using SqlDataSource</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Navy">SqlDataSourceStatusEventArgs Example</h2>
<asp:Label ID="Label1" runat="server" Font-Italic="true" ForeColor="Red"></asp:Label>
<asp:SqlDataSource
ID="SqlDataSource1"
runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT ProductID, ProductName FROM Products"
UpdateCommand="Update Products SET ProductName=@ProductName WHERE ProductID=@ProductID"
OnUpdated="SqlDataSource1_Updated"
>
</asp:SqlDataSource>
<asp:DetailsView
ID="DetailsView1"
runat="server"
DataSourceID="SqlDataSource1"
DataKeyNames="ProductID"
AutoGenerateEditButton="true"
AllowPaging="true"
ForeColor="AliceBlue"
BackColor="CornflowerBlue"
BorderColor="LightBlue"
>
</asp:DetailsView>
</div>
</form>
</body>
</html>