|Bind your parent ListView control that is displaying the categories to a SELECT query that fetches these categories.
Handle the ItemDataBound[^] event for your parent ListView control. This will fire each time data for an individual category is bound to the list control.
The following code demonstrates how to handle this event and use LINQ to get all orders for the child list control associated with a customer from the parent list control. It uses data from the Northwind database. The parent list control is bound to a SqlDataSource control.
protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
string customerID = ((System.Data.DataRowView)((ListViewDataItem)e.Item).DataItem)["CustomerID"].ToString();
ListView listView2 = e.Item.FindControl("ListView2") as ListView;
using (NorthwindModel.NorthwindEntities context = new NorthwindModel.NorthwindEntities())
var orders = (from o in context.Orders
where o.Customers.CustomerID == customerID
listView2.DataSource = orders;
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush