Reputation: 115
Is it possible, to bind two Lists to a Repeater(which creates a Table), to use Data from both Lists?
I have a List with actions and a List with Users. I would like to display some Information about the Action, and about the User who issued the Action. Can I combine the Information about the Action with the Information about the User?
Here's a Sketch of the Table, how it should look like:
ID | Time | Info about Action | UserID | Full Name |Info about User
Jopi
Upvotes: 1
Views: 1220
Reputation: 203812
Rather than binding two data sources and trying to have the Repeater
sort it out, what you need to do is combine the data into a single item before you bind it to the repeater.
As to how you do that, it will depend on how your data is structured.
If the item at the same indexes of both lists are the items that "belong together" then you could just use Zip
.
var query = actions.Zip(users, (a,b)=> new CombinedStructure(a,b));
You could either create a new custom type to store the data that needs to be in each displayed row, or use an anonymous type and assign each field manually.
If the indexes don't correspond then you'll likely need a join
var query = from action in actions
join user in users
on user.ID = action.UserID
select ...
Upvotes: 2
Reputation: 50728
No, but you could use LINQ to join them:
And bind the result.
Upvotes: 1