I have data coming from two tables with a foreign key relationship - one User table containing users of the web application, and one Page table containing details about pages visited by each user.
I would like to be able to view these data in a gridview or the like on a page. It's easy enough to just show the User table data like so (I'm using the Entity Framework and LINQ):
UserDBEntities context = new UserDBEntities();
GridView1.DataSource = from user in context.UserSet
select new { user.Ip, user.Count, user.Description, user.Referer };
GridView1.DataBind();
But how can I show the Page details? I'm not bent on any particular way of showing it, but the only idea I've been able to come up with is to have a dropdown list for each user in a column. But I can't figure out how to get the page data into such a dropdown list. The tables are associated with the primary/foreign key UserID.
The closest I've come to finding something similar to this is this for Linq2SQL: http://weblogs.asp.net/scottgu/archive/2007/07/16/linq-to-sql-part-5-binding-ui-using-the-asp-linqdatasource-control.aspx , and this using more traditional data access: http://www.highoncoding.com/Articles/169_DropDownList_Inside_GridView__Method_1_.aspx . Either way, regardless of data access technology, I can't relate these solutions to my example and get it to work...
Any ideas would be welcome (dropdownlist solution or other)!