Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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)
'Declaration
<BrowsableAttribute(False)> _
<PersistenceModeAttribute(PersistenceMode.InnerProperty)> _
Public ReadOnly Property InsertParameters As ParameterCollection

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 Nothing. 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.5.1, 4.5, 4, 3.5

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.