使用剃刀视图中不同表中的值在标签中显示值

时间:2013-02-18 03:28:59

标签: asp.net-mvc razor

我希望在RoundDetails / Create razor视图的RoundDetails类中显示我的Holes类的Hole_Num值。

这是我的Holes课程:

公共部分类洞     {         公共洞()         {             this.RoundDetails = new HashSet();         }

    public int HoleId { get; set; }
    public int FacilityId { get; set; }
    public int CourseId { get; set; }
    public int TeeTypeId { get; set; }
    public int Hole_Num { get; set; }
    public int Yardage { get; set; }
    public byte Par { get; set; }
    public short Handicap { get; set; }

    public virtual ICollection<RoundDetail> RoundDetails { get; set; }
    public virtual TeeType TeeType { get; set; }
}

这是我的RoundDetails类:

公共部分类RoundDetail     {         public int RoundId {get;组; }         public int GolferId {get;组; }         public int FacilityId {get;组; }         public int CourseId {get;组; }         public int TeeTypeId {get;组; }         public int HoleId {get;组; }         public decimal Differential {get;组; }         public Nullable Date {get;组; }         public byte Score {get;组; }         公共Nullable推杆{得到;组; }         public Nullable GIR {get;组; }         public Nullable FIR {get;组; }         public Nullable Up_And_Down {get;组; }         public Nullable Par_Save {get;组; }         public Nullable Sand_Save {get;组; }         public Nullable Driving_Distince {get;组; }         public Nullable Proximity {get;组; }         public Nullable Green_Fee {get;组; }

    public virtual Course Course { get; set; }
    public virtual Facility Facility { get; set; }
    public virtual Golfer Golfer { get; set; }
    public virtual Hole Hole { get; set; }
    public virtual TeeType TeeType { get; set; }
}

这是我的剃刀观点:

                    <td>
                        @Html.LabelFor(model => model.Hole.Par)

                    </td>

如何使用Holes表中的Par信息填充此标签?我假设使用RoundDetailController的Create方法进行一些操作或创建某种类型的ViewModel是可行的方法,但我不确定是哪一个或如何开始。请帮助!

0 个答案:

没有答案