کل فایل پروژه رو تو چند پست بالاتر قرار دادم. حتی بدون لینک هم ارور میده. مثلا من یه کلاس ساختم:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace BeBook.Models
{
public class User
{
public int IdUser { set; get; }
public string Name { set; get; }
}
}
کنترولر:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace BeBook.Controllers
{
public class UserController : Controller
{
//
// GET: /User/
public ActionResult Index()
{
return View();
}
public ActionResult add()
{
return View();
}
}
}
ویو:
@model IEnumerable<BeBook.Models.User>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.IdUser)
</th>
<th>
@Html.DisplayNameFor(model => model.Name)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.IdUser)
</td>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
</td>
</tr>
}
</table>
باز اروری که عکسش تو پست اول هست رو توی فورایچ میده