我有一個C# MVC Model
如下;從Model C#MVC檢索值
public class MyModel
{
...
public IEnumerable<MyModel> allDetails { get; set; }
public int age { set; get; }
public string gender { set; get; }
public int schoolid { set; get; }
...
}
現在想從allDetails
檢索數據。我該怎麼做 ?
在controller
;
model.allDetails = MyDetails.getAllDetails(); // Saves all details in the Model
現在,我怎麼檢索該model
age, gender and school
;我的方法如下(但不工作)
model.allDetails.age; // This doesn't work
視圖上的代碼是什麼?你確定你是從你的視圖傳遞數據到'allDetails'嗎? – 2013-03-26 08:46:43
輸出不會在視圖中使用。我正在使用模塊的值在控制器內部自行進一步處理。 – 2013-03-26 08:48:40