我想在視圖中顯示兩個表格的元素,但我不知道如何。模型如何用於在視圖中顯示兩個表格
在我看來,我有@model IEnumerable指向'Tmembre'類的模型和表'Tmembre'在數據庫中的對應。 我可以在我的視圖中顯示此表格的元素,行。
但我也想顯示在這個視圖中的另一個表的元素,我不能把其他@modeldéclaration在視圖中。
我嘗試在兩個表的模型中創建一個類,並將sql放入模型中,但我認爲它不在模型中,我必須請求DB。
public class myviewmodel
{
public Tmembre tmembre { get; set; }
public List<Tmembre> GetlstMembre { // SQL }
public TAssociation tassociation { get; set; }
public List<TAssociation> GetlstAssociation { // SQL }
}
刪除了[tag:asp-classic]標籤。 – Paul 2014-11-04 12:40:06