1

I'm binding the ListView with the following code.

List<intermediate> order = new List<intermediate>();
order = DBInteraction.GetAllActiveOrders();
lvProducts.DataSource = order;
lvProducts.DataBind();

my intermediate is as follow:

public class intermediate
{
    public product pro = new product();
    public order ord = new order();
}

now on frontend i'm binding the listview like:

<asp:ListView runat="server" ID="lvProducts" OnItemCommand="lvProducts_ItemCommand">
<ItemTemplate>
    <tr>
        <td>
        <asp:Label runat="server" ID="lblID" Text='<%# Eval(ord.oID) %>'/>
        </td>...

same with Eval("ord.oID"). its throwing exception: The name 'ord' does not exist in the current context. How to bind such object? is i'm on right path?

1 Answer 1

3

It should be this:

<asp:Label runat="server" ID="Label1" Text='<%# DataBinder.Eval(Container.DataItem, "ord.oID") %>'/> 

Instead of this:

<asp:Label runat="server" ID="lblID" Text='<%# Eval(ord.oID) %>'/>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.