简体   繁体   中英

C# CRUD operation in MVC 4 one view

I tried to do a CRUD operation. 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.

You only need to write the View path, something like this

return View( "~/Views/ControllerName/ViewName.cshtml", tbl_country);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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