SqlDataSourceView.Updated イベント
アセンブリ: System.Web (system.web.dll 内)

Dim instance As SqlDataSourceView Dim handler As SqlDataSourceStatusEventHandler AddHandler instance.Updated, handler
public: event SqlDataSourceStatusEventHandler^ Updated { void add (SqlDataSourceStatusEventHandler^ value); void remove (SqlDataSourceStatusEventHandler^ value); }

Updated イベントを処理して、更新操作完了後の出力パラメータの値を調べます。出力パラメータは、イベントに関連付けられている SqlDataSourceStatusEventArgs オブジェクトから得ることができます。

ODBC データベースから取得したデータを GridView コントロールで表示し更新する方法を次のコード例に示します。レコードが正常に更新されると、Updated イベントがイベント ハンドラによって処理され、電子メール メッセージ通知を送信する後処理ステップが実行されます。
<%@Page Language="VB" %> <%@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"> Sub OnDSUpdatedHandler(ByVal source As Object, ByVal e As SqlDataSourceStatusEventArgs) If e.AffectedRows > 0 Then ' Perform any additional processing, such as setting a status label. Label1.Text = Request.LogonUserIdentity.Name & _ " changed user information sucessfully!" Else Label1.Text = "No data updated!" End If End Sub 'OnDSUpdatedHandler </SCRIPT> <HTML> <BODY> <!-- 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 runat="server"> <asp:SqlDataSource id="SqlDataSource1" runat="server" ProviderName="System.Data.Odbc" DataSourceMode="DataSet" ConnectionString="dsn=myodbc3dsn;" SelectCommand="SELECT EmployeeID,FirstName,LastName,Title FROM Employees" UpdateCommand="Update Employees SET FirstName=?,LastName=?,Title=? WHERE 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>
<%@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!"; } } </SCRIPT> <HTML> <BODY> <!-- 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 runat="server"> <asp:SqlDataSource id="SqlDataSource1" runat="server" ProviderName="System.Data.Odbc" DataSourceMode="DataSet" ConnectionString="dsn=myodbc3dsn;" SelectCommand="SELECT EmployeeID,FirstName,LastName,Title FROM Employees" UpdateCommand="Update Employees SET FirstName=?,LastName=?,Title=? WHERE 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>
<%@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> <BODY> <!-- 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 runat="server"> <asp:SqlDataSource id="SqlDataSource1" runat="server" ProviderName="System.Data.Odbc" DataSourceMode="DataSet" ConnectionString="dsn=myodbc3dsn;" SelectCommand="SELECT EmployeeID,FirstName,LastName,Title FROM Employees" UpdateCommand="Update Employees SET FirstName=?,LastName=?,Title=? WHERE 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>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からSqlDataSourceView.Updated イベントを検索する場合は、下記のリンクをクリックしてください。

- SqlDataSourceView.Updated イベントのページへのリンク