bit of a newbie to mvc. i am having trouble with the following scenario:
I have a view with the following:
<tr>
<% foreach (var game in (IEnumerable<Game>)ViewData["Game"])
{ %>
<td>
<input type="checkbox" name="selectedObjects" value="<%=game.Id%>" />
</td>
<td>
<%=game.GMTDateTime%>
</td>
<td>
<%=game.HomeTeamId%>
</td>
<td>
<%=game.AwayTeamId%>
</td>
<td>
<%=game.Venue%>
</td>
</tr>
All of the data displays OK except for HomeId and AwayId. These two fields are linked to another table called team and each Id in HomeTeamId and AwayTeamId relate to a record in the Team table and each id has a "Name". My problem is how do I display the "Name" from the Team table rather than the Id field shown.
The controller shows:
ViewData["Game"] = dc.Games.GetGames();
The query I am using in linq is:
public static IEnumerable<Game> GetGames(this Table<Game> source)
{
return from c in source
orderby c.GMTDateTime
select c;
}