0
내가 MVC에서 데이터베이스에 정보를 보내고 내가 페이지를 리디렉션하고 새로 저장된 데이터를 출력보기를 호출
, 나는 NullReferenceException이 오류가 개체의 인스턴스. "MVC NullReferenceException이
분명히, 내 모델은 null입니다 :
public ActionResult Index()
{
var customer = db.Customer.ToList();
return View();
}
에 의해 호출됩니다 :이 널 왜 이해가 안
[HttpPost]
public ActionResult Create(CustomerModel customer)
{
db.Customer.Add(customer);
db.SaveChanges();
return RedirectToAction("Index");
}
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.CustomerID)
</td>
<td>
@Html.DisplayFor(modelItem => item.Address)
</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>
}
이 내 컨트롤러입니다 ....
Perfect. 고맙습니다. – Subby