• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 404
  • Last Modified:

how can I reset the parameter of an objectdatasource ?

I have two panels. The first panel saves the invoice information (header information).

The second panel saves the invoice lines for this invoice (a gridview with 1 or more lines).

on add of a new invoice, I save the invoice header and then return the invoice id without refreshing the page. The InvoiceID
which is bound to the ObjectDataSource does not get reset. How can I do this ?

The actual insert method (InsertInvoiceLines) is in the business object.

I tried using session variables, even a session variable is not being reset  and I cannot access a session variable in the business object. What other options do I have if I cannot reset the objectdatasource Parameter value ?

<asp:ObjectDataSource  ID="odsInvLines" TypeName="BusinessObject.Invoice" runat="server"
         OldValuesParameterFormatString="original{0}"  SelectMethod="GetInvoiceLinesByInvoiceID" InsertMethod="InsertInvoiceLines" UpdateMethod="UpdateInvoiceLines">
        <UpdateParameters>
        <asp:Parameter Name="InvoiceID" Type="Int64" /> 
        <asp:Parameter Name="Description" Type="String" />
        <asp:Parameter Name="Rev_Activity_Code_ID" Type="Int32" />
        <asp:Parameter Name="Quantity" Type="Int32" />
        <asp:Parameter Name="Unit_Selling_Price" Type="Double" />
        <asp:Parameter Name="Total_Amount" Type="Double" />
        <asp:Parameter Name="BEGIN_BILLING_PERIOD" Type="String" />
        <asp:Parameter Name="END_BILLING_PERIOD" Type="String" />
        <asp:Parameter Name="OriginalLine_Number" Type="Int64" />
        </UpdateParameters>
        
        <InsertParameters >
        <asp:Parameter Name="InvoiceID" Type="Int64" /> 
        <asp:Parameter Name="Description" Type="String" />
        <asp:Parameter Name="Rev_Activity_Code_ID" Type="Int32" />
        <asp:Parameter Name="Quantity" Type="Int32" />
        <asp:Parameter Name="Unit_Selling_Price" Type="Double" />
        <asp:Parameter Name="Total_Amount" Type="Double" />
        <asp:Parameter Name="BEGIN_BILLING_PERIOD" Type="String" />
        <asp:Parameter Name="END_BILLING_PERIOD" Type="String" />
        <asp:Parameter Name="OriginalLine_Number" DefaultValue="0"  Type="Int64" />
        </InsertParameters>
</asp:ObjectDataSource>

Open in new window

0
tech_question
Asked:
tech_question
2 Solutions
 
GiftsonDJohnCommented:
You can access the session variable in Bussiness object.

Add reference to System.Web.dll and use HttpContext.Current.Session["SessionVariable"] to get the session variable.
0
 
NazoUKCommented:
You can change the values in the parameter:

odsInvLines.InsertParameters["InvoiceID"].DefaultValue = (string value)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now