Parameter.Type 屬性

定義

取得或設定參數的類型。

public:
 property TypeCode Type { TypeCode get(); void set(TypeCode value); };
public TypeCode Type { get; set; }
member this.Type : TypeCode with get, set
Public Property Type As TypeCode

屬性值

TypeCode

Parameter 的類型。 預設值是 Object

例外狀況

參數類型不是其中一個 TypeCode 值。

範例

下列程式碼範例示範如何使用 物件做為輸出參數,並使用預存程式傳回值參數時,設定 DefaultValue 物件的 、 TypeDirection 屬性 Parameter 。 此程式碼範例是類別概觀所提供較大範例的 SqlDataSourceStatusEventArgs 一部分。

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

備註

此類型可用來建立強型別參數,讓值在 Web 應用程式和基礎程式碼之間正確轉換。

如果參數的類型已變更,則會 OnParameterChanged 呼叫 方法。

適用於

另請參閱