Parameter.Direction 屬性

定義

表示此 Parameter 物件是否用來將值繫結至控制項,或是這個控制項是否可用來變更該值。Indicates whether the Parameter object is used to bind a value to a control, or the control can be used to change the value.

public:
 property System::Data::ParameterDirection Direction { System::Data::ParameterDirection get(); void set(System::Data::ParameterDirection value); };
public System.Data.ParameterDirection Direction { get; set; }
member this.Direction : System.Data.ParameterDirection with get, set
Public Property Direction As ParameterDirection

屬性值

ParameterDirection

其中一個 ParameterDirection 值。One of the ParameterDirection values. 根據預設,Direction 是設為 InputDirection is set to Input by default.

範例

下列程式碼範例示範如何 DefaultValue Type 在使用預存程式的 Direction Parameter 輸出參數和傳回值參數時,設定物件的、和屬性。The following code example demonstrates how to set the DefaultValue, Type, and Direction properties of Parameter objects when using them as output parameters and return value parameters with a stored procedure. 這個程式碼範例是針對類別總覽提供的較大範例的一部分 SqlDataSourceStatusEventArgsThis code example is part of a larger example provided for the SqlDataSourceStatusEventArgs class overview.

<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>
<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>

備註

Direction 屬性目前未由 Parameter 類別使用,並保留供日後使用。The Direction property is currently not used by the Parameter class and is reserved for future use.

Direction屬性描述實例所系結之值 Parameter 與物件本身之間的資料流程方向 ParameterThe Direction property describes the direction of the flow of data between the value that a Parameter instance is bound to and the Parameter object itself. 屬性的預設值 Direction Input 會描述最常見的案例,也就是資料的流程一律為一個方向:從物件系結至物件的值 Parameter ParameterThe default value for the Direction property, Input, describes the most common scenario where the flow of data is always in one direction: from the value to which the Parameter object is bound to the Parameter object. 對基礎值所做的任何變更都會由 Parameter 物件反映,但 Parameter 基礎資料並不會反映對物件所做的任何變更。Any changes made to the underlying value are reflected by the Parameter object, but any changes to the Parameter object are not reflected by the underlying data. 您可以在使用 Direction InputOutput Output 輸出參數時,或在使用 ReturnValue 預存程式的傳回值時,將屬性設定為或。You can set the Direction property to InputOutput or Output when working with output parameters, or ReturnValue when working with a return value from a stored procedure.

如果 Direction 參數的屬性變更,則 OnParameterChanged 會呼叫方法。If the Direction property of the parameter is changed, the OnParameterChanged method is called.

適用於