?
Solved

how can I reset the parameter of an objectdatasource ?

Posted on 2009-04-27
2
Medium Priority
?
399 Views
Last Modified: 2013-11-08
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
Comment
Question by:tech_question
2 Comments
 
LVL 14

Accepted Solution

by:
GiftsonDJohn earned 1200 total points
ID: 24247366
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
 
LVL 15

Assisted Solution

by:NazoUK
NazoUK earned 800 total points
ID: 24248161
You can change the values in the parameter:

odsInvLines.InsertParameters["InvoiceID"].DefaultValue = (string value)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month14 days, 16 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question