You need to use the Html.Partial()
helper instead of Html.RenderPartial()
.
Try:
@Html.Partial("_SelectAllDrChemistSales", ViewData);
This will render the partial and send through the whole ViewData
.
If you need to display the items in a list, for example, you can then use:
<ul>
@for (var item in ViewData["myItems"]) // Or whatever your list is called in ViewData
{
<li>@item</li>
}
</ul>
Although, like @Henk points out in his answer, you're far better off forgetting about ViewData
and ViewBag
as a method of getting your data into the views and look into view models. This will then give you automatic model binding, which will take 90% of the work you're going to potentially encounter if you carry on down the ViewData/ViewBag
route.