Reputation: 13008
In my mvc project i have a controller with the following actions:
public ActionResult Index()
{
return View(new List<Product>());
}
The corresponding index view render a partial view with the master grid:
@model System.Collections.Generic.List<TbbModels.Domain.Product>
@Html.Partial("_ProdutoMasterGrid", Model)
This partial view have a submit button and a grid. The client needs to put some data in the form and submit it to that action:
public ActionResult _ProdutoMasterGrid(string param)
{
return PartialView("_ProdutoMasterGrid",
repository.Compare(param).ToList());
}
But than i get the grid without the layout. How can i return a partial view with the layout?
Upvotes: 0
Views: 270
Reputation: 28747
You should explicitly return the correct view:
public ActionResult _ProdutoMasterGrid(string param)
{
return View("Index",
repository.Compare(param).ToList());
}
This ensures that when you do a post to this action, it returns the index view. I'm supposing here that repository.Compare
return a List<Product>
as well, since the type needs to match.
Upvotes: 1