I'm trying to get better with asp.net mvc5 how ever I've ran into a problem. I've made Gamemodel where you can create games. On my post/create I get a drop down list for the games I've added on my Game model.
I also have my 'Title / Next game' I want a drop-down list on that as-well. But right now it just takes a string, but I would like a drop-down list like for GameId how can I achieve this ?
This is my Post Model
public class Post
{
[Key]
public int PostId { get; set; }
//URL
[Display(Name = "URL")]
[StringLength(80)]
public string Url { get; set; }
//User
[Display(Name = "User")]
public virtual ApplicationUser User { get; set; }
//Game
[Display(Name = "Game")]
public int GameId { get; set; }
[Display(Name = "Next Game")]
public string Title { get; set; }
public virtual Game Game { get; set; }
//Time
private DateTime? _date;
public DateTime? Date
{
get
{
if (_date == null || _date.ToString() == "1/1/0001 12:00:00 AM")
{
return _date = DateTime.Now;
}
return _date;
}
set
{
_date = value;
}
}
And this is my Game Model
public class Game
{
[Key]
public int GameId { get; set; }
//Game
[Display(Name = "Game")]
public string Title { get; set; }
//User
[Display(Name = "User")]
public virtual ApplicationUser User { get; set; }
}
Aucun commentaire:
Enregistrer un commentaire