我想獲取數據並顯示每個循環內的數據。請在MVC中提供示例代碼完整的新手。是否有任何方法調用在Mvc Foreach循環內的方法
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.cntryName)
//---- Here I want to call another method based on contryId and bind details
in another table
</td>
您並使用ajax並調用您的控制器,然後將結果解析到您的視圖。一些例子:http://www.binaryintellect.net/articles/218ca630-ba50-48fe-af6e-6f754b5894aa.aspx – freshbm
http://stackoverflow.com/questions/22843324/calling-controller-action-method-directlyrom -razor-view – NnN