简体   繁体   English

MVC 4中的C#CRUD操作一个视图

[英]C# CRUD operation in MVC 4 one view

I tried to do a CRUD operation. 我试图进行CRUD操作。 Operation is that if user clicks on Edit from grid then data should be shown in the control that is below the grid. 操作是,如果用户单击“从网格编辑”,则数据应显示在网格下方的控件中。 It means, grid and controls are in same page. 这意味着网格和控件在同一页面中。 Below is the code: 下面是代码:

 @Html.ActionLink("Edit", "Update", new {  id=item.Country_ID  }) 

In controller : 在控制器中:

 [HttpPost]
    public ActionResult Update(TBL_Country tbl_country)
    {
        if (ModelState.IsValid)
        {
            db.Entry(tbl_country).State = EntityState.Modified;
            db.SaveChanges();                
        }
        return View(tbl_country);
    }

But, it shows an error stating : 但是,它显示了一个错误,指出:

It does not have any views. 它没有任何意见。 How can I give the same page view again? 如何再次提供相同的页面视图?

I am a beginner in MVC4. 我是MVC4的初学者。

You only need to write the View path, something like this 您只需要编写View路径,就像这样

return View( "~/Views/ControllerName/ViewName.cshtml", tbl_country); 返回View(“〜/ Views / ControllerName / ViewName.cshtml”,tbl_country);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM