-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());' –