如何将idt添加到堆栈顶部并使其不可为空 [英] How do I add the idt to the top of the stack and make it non nullable
本文介绍了如何将idt添加到堆栈顶部并使其不可为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想首先在List< Table1>中添加一行然后在更新mdf数据库的同时显示结果。我收到此错误代码:
I am trying to first Add a row to "List<Table1>" then display the results at the same time updating the mdf database. I get this error code:
The parameters dictionary contains a null entry for parameter 'Idt' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult EditAction(Int32, System.String, System.String, System.String)' in 'EditTables.Controllers.HomeController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters
Idt定义为Identity(1,1),如果无效则无关紧要。如何将idt添加到堆栈顶部并使其不可为空?
Idt is defined as "Identity(1,1)" and should not matter if nulled. How do I add the idt to the top of the stack and make it non nullable?
public class HomeController : Controller
{
private testContext db = new testContext();
List<Table1> thistable = new List<Table1>
[HttpPost]
public ActionResult AddAction()
{
thistable = db.Data1.ToList();
if (thistable != null)
{
thistable.Add(new Table1 { datetime0 = DateTime.Now.ToString(), col1 = Request.Form["c1"].ToString(), col2 = Request.Form["c2"].ToString(), col3 = Request.Form["c3"].ToString() });
db.Data1.Add(new Table1 { datetime0 = DateTime.Now.ToString(), col1 = Request.Form["c1"].ToString(), col2 = Request.Form["c2"].ToString(), col3 = Request.Form["c3"].ToString() });
db.SaveChanges();
return View(thistable);
}
else
{
return null;
}
}
推荐答案
您的示例的第三行中有错误。
You have an error in the third row of your example.
这篇关于如何将idt添加到堆栈顶部并使其不可为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文