Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


MVC Newbie - Get Team Name Using ID in Another Table

MVC Newbie - Get Team Name Using ID in Another Table

MVC Newbie - Get Team Name Using ID in Another Table

I am creating a softball schedule app that will be used by multiple teams.

I have a table the has team info - id, name, coach, etc
I have a table that has game info - id, date, teamid, opponentid, outcome

Here are the two models:

CODE --> c#

namespace softball.Models
	public class Team
		public int iTeamID { get; set; }
		public string sTeamName { get; set; }
		public string sCoach { get; set; }

CODE --> c#

namespace softball.Models
	public class Game
		public int iGameID { get; set; }
		public int iTeamID { get; set; }
		public DateTime dtDate { get; set; }
		public int iOpponentID { get; set; }
		public byte? tiOutcome { get; set; }

I know how to use LINQ to pass a model into my view that can return a list of games for a particular team, but of course it shows an ID number for the two teams involved and not the team names. How can I make it show the team names without resorting to doing data calls in the View itself?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close