-3
我有以下型号:呈现在asp.net C#MVC局部视图或行动
public partial class CityMaster
{
public int id { get; set; }
public string cityname { get; set; }
}
public partial class CityJourny
{
public int journyId { get; set; }
public int fromCity { get; set; } //foreign key from citymaster
public int ToCity { get; set; } //foreign key from citymaster
public string description { get; set; }
public string distance { get; set; }
}
//View model
public partial class VMCity
{
public CityMaster cm { get; set; }
public List<CityJourny> cj { get; set; }
}
cityview.cshtml:
@model APIModels.UserModel.VMCity
@{
ViewBag.Title = "View1";
}
<h2>View1</h2>
<fieldset>
<legend>VMCity</legend>
@Html.DisplayFor(model => model.cm.cityname)
@* hear I would like to display list of city from city *@
@Html.Partial("Partial1",new APIModels.UserModel.VMCity());
</fieldset>
<p>
@Html.ActionLink("Edit", "Edit", new { /* id=Model.PrimaryKey */ }) |
@Html.ActionLink("Back to List", "Index")
</p>
我应该在我的控制器行动写入显示城市数据和城市距离列表(我们提供从一个城市到其他城市的巴士服务)
你有什么累的内部城市名单? –
后部分1代码 –
'@ Html.Partial(“Action”,“Controller”,new APIModels.UserModel.VMCity());' –