SqlDataSourceView.SelectCommandType 속성

정의

SelectCommand 속성의 텍스트가 SQL 쿼리와 저장 프로시저의 이름 중 어느 것인지를 나타내는 값을 가져오거나 설정합니다.

public:
 property System::Web::UI::WebControls::SqlDataSourceCommandType SelectCommandType { System::Web::UI::WebControls::SqlDataSourceCommandType get(); void set(System::Web::UI::WebControls::SqlDataSourceCommandType value); };
public System.Web.UI.WebControls.SqlDataSourceCommandType SelectCommandType { get; set; }
member this.SelectCommandType : System.Web.UI.WebControls.SqlDataSourceCommandType with get, set
Public Property SelectCommandType As SqlDataSourceCommandType

속성 값

SqlDataSourceCommandType 값 중 하나입니다. 기본값은 Text 값입니다.

예외

선택한 값이 SqlDataSourceCommandType 값 중 하나가 아닌 경우

예제

다음 코드 예제에는 설정 하는 방법을 보여 줍니다.는 SelectCommand 저장된 프로시저의 이름으로는 텍스트 및 SelectCommandType 속성을는 StoredProcedure Microsoft SQL Server 데이터베이스에서 데이터를 검색에서 표시 하는 값을 DropDownList입니다.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">

            <asp:DropDownList
                id="DropDownList1"
                runat="server"
                DataTextField="LastName"
                DataSourceID="SqlDataSource1" />

            <asp:SqlDataSource
                id="SqlDataSource1"
                runat="server"
                ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
                SelectCommandType="StoredProcedure"                
                SelectCommand="sp_lastnames">
            </asp:SqlDataSource>

            <!--
                The sp_lastnames stored procedure is
                CREATE PROCEDURE sp_lastnames AS
                   SELECT LastName FROM Employees
                GO
            -->

        </form>
    </body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">

            <asp:DropDownList
                id="DropDownList1"
                runat="server"
                DataTextField="LastName"
                DataSourceID="SqlDataSource1" />

            <asp:SqlDataSource
                id="SqlDataSource1"
                runat="server"
                ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
                SelectCommandType = "StoredProcedure"
                SelectCommand="sp_lastnames">
            </asp:SqlDataSource>

            <!--
                The sp_lastnames stored procedure is
                CREATE PROCEDURE sp_lastnames AS
                   SELECT LastName FROM Employees
                GO
            -->

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

설명

값을 SelectCommandType 속성은 뷰 상태에 저장 됩니다.

적용 대상

추가 정보