我在MVC ASP.NET項目中遇到問題。 我使用LINQ technology.When工作,我想插入一條記錄表,這個錯誤是shown.although插入動作預製:**未能執行索引操作
錯誤:
Server Error in '/' Application. The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Index(Int32)' in 'MVCJahan_oil.Controllers.getehController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
用於插入控制器方法(創建) :
public ActionResult Index(int id)
{
var query= from gete in l_class.getehs where gete.request_no == id select gete;
this.Session["req_no"] = id;
return View(query.ToList());
}
[HttpPost]
public ActionResult Create([Bind(Exclude = "id")]geteh gte)
{
try
{
l_class.getehs.InsertOnSubmit(gte);
l_class.SubmitChanges();
return RedirectToAction("Index", new { id = System.Convert.ToInt32 (Session["req_no"].ToString()) });
}
catch
{
return View();
}
}
您可能需要更新您的問題的標題是有點更具描述性的...... – James 2010-12-11 11:52:34