SqlDataSourceStatusEventArgs 클래스

정의

데이터 작업이 완료된 후 SqlDataSource 컨트롤에서 발생시키는 이벤트에 대한 데이터를 제공합니다.

public ref class SqlDataSourceStatusEventArgs : EventArgs
public class SqlDataSourceStatusEventArgs : EventArgs
type SqlDataSourceStatusEventArgs = class
    inherit EventArgs
Public Class SqlDataSourceStatusEventArgs
Inherits EventArgs
상속
SqlDataSourceStatusEventArgs

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 SqlDataSourceStatusEventArgs 반환 값의 및 값을 사용 하는 경우 반환 되는 출력 매개 변수를 검사 하는 클래스를 SqlDataSource 채우는 저장된 프로시저를 사용 하 여 컨트롤을 GridView 컨트롤. 에 표시 되는 데이터를 선택 하는 저장된 프로시저는 GridView, 또한 정수 출력 매개 변수 및 반환 값 등 호출자에 게 다시 기타 정보를 전달 합니다. 매개 변수는 합니다 SqlDataSource 저장된 프로시저를 사용 하 여 포함 된를 SelectParameters 컬렉션 웹 폼에서 정보를 저장된 프로시저에 전달 하는 매개 변수 구성 뿐만 아니라 정보를 전달 하는 매개 변수를는 폼입니다. 합니다 Direction 이러한 매개 변수 속성 OutputReturnValue합니다.

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

<script runat="server">
// Clicking the Submit button explicitly refreshes the data 
// by calling the Select() method.
private void Submit(Object source, EventArgs e) {
  SqlDataSource1.Select(DataSourceSelectArguments.Empty);
}

// This event handler is called after the Select() method is executed.
private void OnSelectedHandler(Object source, SqlDataSourceStatusEventArgs e) {

  IDbCommand cmd = e.Command; 
  
  Label1.Text = "Parameter return values: ";

  foreach (SqlParameter param in cmd.Parameters) {
    //  Extract the value of the parameter.
    Label1.Text += param.ParameterName + " - " + param.Value.ToString();
  }
}
</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="getordertotal"
            onselected="OnSelectedHandler">
            <selectparameters>
              <asp:querystringparameter name="empId" querystringfield="empId" />
              <asp:parameter name="total" type="Int32" direction="Output" defaultvalue="0" />
              <asp:parameter name="_ret" type="Int32" direction="ReturnValue" defaultvalue="0" />
            </selectparameters>
        </asp:sqldatasource>
        <!--
          CREATE PROCEDURE dbo.getordertotal
            @empId int,
            @total int OUTPUT
          as
            set nocount on
            select @total    = count(1) from orders where employeeid=@empid;
            select * from orders where employeeID = @empId ;
            return (-1000);
          GO
        -->

        <asp:gridview
          id="GridView1"
          runat="server"
          allowpaging="True"
          pagesize="5"
          datasourceid="SqlDataSource1" />

        <asp:button
          id="Button1"
          runat="server"
          onclick="Submit"
          text="Refresh Data" />

        <asp:label id="Label1" runat="server" />

    </form>
  </body>
</html>
<%@Page  Language="VB" %>
<%@Import Namespace="System.Data" %>
<%@Import Namespace="System.Data.Common" %>
<%@Import Namespace="System.Data.SqlClient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
' Clicking the Submit button explicitly refreshes the data 
' by calling the Select() method.
Private Sub Submit(source As Object, e As EventArgs)
  
  SqlDataSource1.Select(DataSourceSelectArguments.Empty)
  
End Sub ' Submit

' This event handler is called after the Select() method is executed.
Private Sub OnSelectedHandler(source As Object, e As SqlDataSourceStatusEventArgs)

  Dim cmd As IDbCommand 
  cmd = e.Command
  Dim param As SqlParameter
  
  Label1.Text = "Parameter return values: "
  
  For Each param In cmd.Parameters
    
    ' Extract the name and value of the parameter.
    Label1.Text = Label1.Text & param.ParameterName & " - " & _
                  param.Value.ToString()

  Next

End Sub ' OnSelectedHandler
</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="getordertotal"
            onselected="OnSelectedHandler">
            <selectparameters>
              <asp:querystringparameter name="empId" querystringfield="empId" />
              <asp:parameter name="total" type="Int32" direction="Output" defaultvalue="0" />
              <asp:parameter name="_ret" type="Int32" direction="ReturnValue" defaultvalue="0" />
            </selectparameters>
        </asp:sqldatasource>
        <!--
          CREATE PROCEDURE dbo.getordertotal
            @empId int,
            @total int OUTPUT
          as
            set nocount on
            select @total    = count(1) from orders where employeeid=@empid;
            select * from orders where employeeID = @empId ;
            return (-1000);
          GO
        -->

        <asp:gridview
          id="GridView1"
          runat="server"
          allowpaging="True"
          pagesize="5"
          datasourceid="SqlDataSource1" />

        <asp:button
          id="Button1"
          runat="server"
          onclick="Submit"
          text="Refresh Data" />

        <asp:label id="Label1" runat="server" />

    </form>
  </body>
</html>

설명

SqlDataSourceStatusEventArgs 클래스에서 사용 됩니다 합니다 Selected, Updated, Inserted, 및 Deleted 데이터에서 수행 된 후 데이터베이스 작업에 대 한 정보를 전달 하는 이벤트 소스 제어 합니다. 작업에 의해 영향을 받는 행 수를 포함 하는이 정보는 DbCommand 발생 하는 모든 예외 정보와 작업을 수행 하는 데이터 원본 개체입니다. 처리 하는 이벤트 처리기 대리자를 추가 하 여 합니다 Selected, UpdatedInserted 또는 Deleted 이벤트를이 데이터를 검사 하 고 필요한 모든 추가 사후 처리를 수행할 수 있습니다.

SqlDataSource 컨트롤 데이터 작업을 사용 하는 동안 기본 데이터 개체를 사용 하 여 작업을 처리할 수 있는 많은 이벤트를 노출 합니다. 다음 표에서 이벤트를 나열 하 고 연결 된 EventArgs 및 수명 주기를 사용 하 여 데이터 작업에 해당 하는 다양 한 이벤트를 소개 하기 위해 이벤트 처리기 클래스는 SqlDataSource 제어 합니다.

이벤트 EventArgs 이벤트 처리기
Selecting 데이터를 검색 하기 전에 발생 합니다. SqlDataSourceSelectingEventArgs SqlDataSourceSelectingEventHandler
Inserting하십시오 Updating, Deleting 업데이트 또는 삭제 작업이 수행 되는 삽입 하기 전에 발생 합니다. SqlDataSourceCommandEventArgs SqlDataSourceCommandEventHandler
SelectedInserted, Updated, Deleted 데이터 검색, 삽입, 업데이트 후에 발생 또는 삭제 작업을 완료 합니다. SqlDataSourceStatusEventArgs SqlDataSourceStatusEventHandler

생성자

SqlDataSourceStatusEventArgs(DbCommand, Int32, Exception)

지정된 출력 매개 변수, 반환 값 및 데이터베이스 작업의 영향을 받은 행 수를 사용하여 SqlDataSourceStatusEventArgs 클래스의 새 인스턴스를 초기화합니다.

속성

AffectedRows

데이터베이스 작업의 영향을 받은 행 수를 가져옵니다.

Command

데이터베이스에 전송된 데이터베이스 명령을 가져옵니다.

Exception

데이터 작업 중 데이터베이스에서 throw하는 예외에 대한 래퍼를 가져옵니다.

ExceptionHandled

데이터베이스에서 throw한 예외가 처리되었는지 여부를 나타내는 값을 가져오거나 설정합니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보