HomeController.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcApplication1.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
List<int> ids = new List<int>();
for (int i = 0; i <= 100; i += 10)
ids.Add(i);
return View(ids);
}
public ActionResult Index2(int id)
{
List<int> ids = new List<int>();
for (int i = id + 1; i <= id + 10; i++)
ids.Add(i);
return View(ids);
}
}
}2.视图
Index.cshtml:
@model List<int>
@{
Layout = null;
}
<table>
@foreach (var item in Model)
{
<tr>
<td>@item</td>
</tr>
<tr>
<td>[color=Red]@Html.Action("Index2", new { id = @item })[/color]</td>
</tr>
}
</table>Index2.cshtml:
@model List<int>
@{
Layout = null;
}
<table><tr><td>@string.Join(",", Model)</td></tr></table>
评论(0)
暂无评论。