LinqDataSource.InsertParameters プロパティ

定義

挿入操作中に使用されるパラメーターのコレクションを取得します。

public:
 property System::Web::UI::WebControls::ParameterCollection ^ InsertParameters { System::Web::UI::WebControls::ParameterCollection ^ get(); };
[System.ComponentModel.Browsable(false)]
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.ParameterCollection InsertParameters { get; }
[<System.ComponentModel.Browsable(false)>]
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.InsertParameters : System.Web.UI.WebControls.ParameterCollection
Public ReadOnly Property InsertParameters As ParameterCollection

プロパティ値

挿入操作中に使用されるパラメーター。

属性

次の例は、InsertParameters コレクションの既定値を提供するパラメーターを持つLinqDataSource コントロールを示しています。 ユーザーが Category プロパティの値を指定しない場合、パラメーターによって指定された既定値がデータベースに保存されます。

<asp:LinqDataSource 
    ContextTypeName="ExampleDataContext" 
    TableName="Products" 
    EnableUpdate="true"
    EnableInsert="true"
    ID="LinqDataSource1" 
    runat="server">
    <UpdateParameters>
      <asp:Parameter Name="Category" DefaultValue="Miscellaneous" />
    </UpdateParameters>
    <InsertParameters>
      <asp:Parameter Name="Category" DefaultValue="Miscellaneous" />
    </InsertParameters>
</asp:LinqDataSource>
<asp:GridView 
    DataSourceID="LinqDataSource1"
    ID="GridView1" 
    runat="server">
</asp:GridView>
<asp:LinqDataSource 
    ContextTypeName="ExampleDataContext" 
    TableName="Products" 
    EnableUpdate="true"
    EnableInsert="true"
    ID="LinqDataSource1" 
    runat="server">
    <UpdateParameters>
      <asp:Parameter Name="Category" DefaultValue="Miscellaneous" />
    </UpdateParameters>
    <InsertParameters>
      <asp:Parameter Name="Category" DefaultValue="Miscellaneous" />
    </InsertParameters>
</asp:LinqDataSource>
<asp:GridView 
    DataSourceID="LinqDataSource1"
    ID="GridView1" 
    runat="server">
</asp:GridView>

注釈

通常、挿入操作に必要な値は、データ バインド コントロールによって LinqDataSource コントロールに渡されます。 既定値を指定する場合、または空の値を nullに変換するかどうかを定義する場合は、挿入パラメーターを指定します。 挿入されるすべての値にパラメーターを指定する必要はありません。これは、ユーザーが値を指定しない場合に処理する必要がある値に対してのみです。

InsertParameters コレクションに指定した値は、データ ソースで定義されているが、データ コントロールにバインドされていないフィールドにのみ使用されます。 たとえば、データベース テーブルに Name、Address、PostalCode という名前の列があり、テーブルにバインドされている ListView コントロールが [名前] フィールドと [住所] フィールドにのみバインドされているとします。 InsertParameters コレクションの値は、PostalCode フィールドにのみ使用されます。 [名前] フィールドと [住所] フィールドには使用されません。 これは、これらのフィールドに値が入力されていない場合でも当てはまります。 データ バインド コントロールがデータ ソース内のすべてのフィールドのフィールドを自動生成する場合、 InsertParameters コレクションの値は使用されません。

適用対象