The most clean solution is building a view model:
public class MatchViewModel
{
public MatchViewModel(Match match) {...}
public DateTime? MatchDate {get;set;}
public string TeamAName {get;set;}
public string TeamBName {get;set;}
}or you just override Team.ToString() to output Name. -Markus 2009/7/25 SteamAnger <[email protected]> > > I thought this was a solution: > > <asp:GridView ID="gvMatches" runat="server"> > <Columns> > <asp:BoundField DataField="HomeTeam.Name" /> > </Columns> > ... > </asp:GridView> > > But the webserver just says that it cant find HomeTeam.Name. :( > > On 25 Juli, 16:02, SteamAnger <[email protected]> wrote: > > I have a class with the name Match. A match consists of a home team > > and a away team and a date. It looks like this: > > > > [ActiveRecord] > > public class Match : Base<Match> > > { > > [PrimaryKey] > > public int MatchId { get; set; } > > [BelongsTo("HomeTeamId")] > > public Team HomeTeam { get; set; } > > [BelongsTo("AwayTeamId")] > > public Team AwayTeam { get; set; } > > [Property] > > public DateTime? MatchDate { get; set; } > > } > > > > Now when I am coding the web page UI I want it to looks like this: > > > > 2008-01-02 TeamA vs TeamB > > 2008-02-02 TeamC vs TeamBarcelona > > 2008-04-12 TeamE vs TeamF > > > > The problem is when I get all my match objects to a list and binds it > > to a gridview the Team objects will not be visible in the gridview, > > only the dates. Code example: > > > > List<Match> lstMatches = new List<Match>(Match.FindAll()); > > gvMatches.DataSource = lstMatches; > > gvMatches.DataBind(); > > > > The Team class looks like this: > > > > [ActiveRecord] > > public class Team : Base<Team> > > { > > [PrimaryKey] > > public int TeamId { get; set; } > > [Property] > > public string Name { get; set; } > > } > > > > What is the best solution? Thanks! > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~----------~----~----~----~------~----~------~--~---
