-1

I have a controller which returns a list of object, i need to display it to a partialview. So what I want is that the partial view inside the non partial view will accept the result and not the non partial view.

This is the "NON" partial view named "Index"

My table headers are here:

<tbody>
     @Html.RenderPartial()
     Action("DashboardSearchResult","Dashboard",new { List<ReservationType> reservationList})
</tbody>

This is my partial view named "_Dashboard"

@model IEnumerable<HotelOrganization.Models.ReservationType>
@foreach (var item in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => item.ReservationId)</td>
<td>@Html.DisplayFor(modelItem => item.ReservationStartDate)</td>
<tr>

This is my controller:

public PartialViewResult DashboardSearchResult(List<ReservationType>reservationList)
{
return PartialView("~/Views/Shared/_Dashboard", reservationList);
}
  • Use div id and load it on click event of button $("#Grid").load("../Controller/Action") – Pathik Tailor Nov 20 '16 at 16:17
  • Hi.I think that you should use something like that.[link](http://stackoverflow.com/questions/5586327/how-to-use-ajax-actionlink).Let me give you brief, explain.If you want to load your data on-demand and don't reload all page use ajax request to your controller. – Qwerty Qwerty Nov 20 '16 at 16:24
  • Its `@Html.Action("DashboardSearchResult","Dashboard",new { reservationList = yourListofReservationType })` (not clear where you list comes from - does you model have a property for it?) –  Nov 20 '16 at 22:14
  • never mind people, i asked the answer already and corrected my mistake, thanks for all the help anyway – John Masqued Nov 21 '16 at 13:56

1 Answers1

0

You can Render the partial Action Directly inside your .cshtml code like this

@Html.RenderAction Or @Html.Action

You can also use @pathik suggestion but it will send one more request to do same thing.

Anirudha Gupta
  • 9,073
  • 9
  • 54
  • 79