I have the following code that seems like it should set my insertParameter but everytime an insert happens it uses the default parameter. Do i need to do anything special to make this work?
Codebehind:
protected void SetInsertParams(object sender, LinqDataSourceInsertEventArgs e)
{
if (lbl_Personnel.Visible)
{
lds_Personnel.InsertParameters["BudgetLineTypeCode"].DefaultValue = "S";
}
else if(lbl_Operating.Visible)
{
lds_Personnel.InsertParameters["BudgetLineTypeCode"].DefaultValue = "O";
}
else if (lbl_SubContractor.Visible)
{
lds_Personnel.InsertParameters["BudgetLineTypeCode"].DefaultValue = "C";
}
}
From my aspx page:
<asp:LinqDataSource ID="lds_Personnel" runat="server" OnSelecting="SetParams"
ContextTypeName="nrm.FRGPproposal.FrgpropDataContext"
TableName="BudgetLines" OnInserted="lds_Personnel_OnInserted" OnInserting="SetInsertParams"
Where="ProposalID == @PropNumber && BudgetLineTypeCode == @BudgetLineTypeCode"
EnableDelete="True" EnableInsert="True" EnableUpdate="True">
<WhereParameters>
<asp:SessionParameter Name="PropNumber" SessionField="PropNumber" Type="Int32" />
<asp:Parameter DefaultValue="S" Name="BudgetLineTypeCode" Type="Char" />
</WhereParameters>
<InsertParameters>
<asp:SessionParameter Name="ProposalID" SessionField="PropNumber" Type="Int32"/>
<asp:Parameter DefaultValue="S" Name="BudgetLineTypeCode" Type="Char" />
</InsertParameters>
</asp:LinqDataSource>