Can't set LinqDataSource InsertParameters from my code behind.
Posted
by Abe Miessler
on Stack Overflow
See other posts from Stack Overflow
or by Abe Miessler
Published on 2010-03-31T15:26:55Z
Indexed on
2010/03/31
16:23 UTC
Read the original article
Hit count: 661
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>
© Stack Overflow or respective owner