0
votes

I have an ASP.NET Page. It creates a datasource like this:

 <asp:ObjectDataSource ID="uxOrderSource" runat="server" SelectMethod="OrdersGetOne" TypeName="Vevo.Domain.DataSources.OrdersDataSource">
 <selectparameters>
     <asp:QueryStringParameter Name="orderID" QueryStringField="OrderID" Type="String" />
 </selectparameters>
 </asp:ObjectDataSource>

And then it uses the datasource here like this:

 <asp:FormView ID="uxOrderView" runat="server" DataSourceID="uxOrderSource" CssClass="CheckoutCompleteCustomerFormView">

And then it references the email field in that datasource like so:

<%# Eval("Email") %>

My Problem is, way before this form is created on the page, I need to pull that email out and set a script var with its value, so that I can use it while the order line items are being iterated. Because for every order line item (which happens on the page BEFORE the form is created) I need to call a third party API and send in line item information, but that line item info also needs an email, and the email does not exist in the order line item datasource.

1
Did you try ObjectDataSource.Select method yet? - Tariqulazam
let's see, I am so new, I don't even know how to search for what I need, I'll look this up - KacieHouser
Give it a go and let me know if you need further help. Good luck. - Tariqulazam
Your problem is not so clear, we could help you out faster if you edit your question to be more concrete. - Jupaol
I just need to access a fields value in a datasource without using the datasource in something like a formview or gridview - KacieHouser

1 Answers

1
votes

Based on this:

I just need to access a fields value in a datasource without using the datasource in something like a formview or gridview

The easiest way is to bind your GridView or FormView manually in code behind using this:

protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
    {
        this.myGridView.DataSource = this.GetYourDataSourceManually();
        this.myGridView.DataBind();
    }
}

If you want to use a script, I think there are two ways, either render the GridView with the data you want and then use JQuery to find each element already rendered and use it to call your third party API

Or..

Expose a Web Service (A PageMethod to keep it simple) with the data you want to consume on the client side using JQuery

I have a lot of functional samples on my GitHub site: