Yes. You can use a data binding expression to do this. Below I have posted the code for a page that displays a hierarchical list of customers with orders from the sample Northwind database using ADO.NET Entity Framework. I use a databinding expression in the child list control displaying order details to display the customer's country against every order. The databinding expression is a bit clumsy (lots of calls to .Parent) but it works. ASPX code: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
- <%#Eval("CustomerID") %>
- <%#Eval("OrderID") %> <%#((NorthwindModel.Customers)((ListViewDataItem)Container.Parent.Parent.Parent).DataItem).Country %>
Code-behind file: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { using (NorthwindModel.NorthwindEntities context = new NorthwindModel.NorthwindEntities()) { ListView1.DataSource = from c in context.Customers orderby c.CustomerID select c; ListView1.DataBind(); } } protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e) { string customerID = ((NorthwindModel.Customer