Export (0) Print
Expand All

LinqDataSource.InsertParameters Property

Gets the collection of parameters that are used during an insert operation.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

[PersistenceModeAttribute(PersistenceMode.InnerProperty)]
[BrowsableAttribute(false)]
public ParameterCollection InsertParameters { get; }

Property Value

Type: System.Web.UI.WebControls.ParameterCollection
The parameters that are used during an insert operation.

Typically the values that are needed for an insert operation are passed to the LinqDataSource control by the data-bound control. You specify insert parameters when you want to provide a default value or define whether to convert empty values to null. You do not have to provide a parameter for every value that will be inserted, only for the values that must be handled when the user does not provide a value.

The values that you provide in the InsertParameters collection are used only for fields that are defined in the data source but that are not bound in the data control. For example, suppose a database table has columns that are named Name, Address, and PostalCode, but a ListView control that is bound to the table is bound only to the Name and Address fields. The values in the InsertParameters collection will be used only for the PostalCode field. They will not be used for the Name and Address field. This is true even if no value is entered for those fields. If the data-bound control autogenerates fields for all fields in the data source, no values from the InsertParameters collection will be used.

The following example shows a LinqDataSource control with a parameter that provides a default value in the InsertParameters collection. If the user does not provide a value for the Category property, the default value that is provided by the parameter is saved in the database.


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


.NET Framework

Supported in: 4, 3.5

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft