我想获取数据并显示每个循环内的数据。请在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