Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save joshi-kumar/0dd05ea6d911073b3cafd1b60848d543 to your computer and use it in GitHub Desktop.
Save joshi-kumar/0dd05ea6d911073b3cafd1b60848d543 to your computer and use it in GitHub Desktop.
Pass viewbag value from view to partial view
Main view =>
@Html.Partial("_CatalogSelectors", Model.PagingFilteringContext, new ViewDataDictionary { { "pageTotal", ViewBag.pageTotal },{"productTotal", ViewBag.TotalProduct},{"productName",Model.Name} })
Get in partial view =>
@{
string pageTotal = Convert.ToString(ViewData["pageTotal"]);
string productTotal = Convert.ToString(ViewData["productTotal"]);
string productName = Convert.ToString(ViewData["productName"]);
}
use in partial view=>
<h5>
@if (Convert.ToInt32(productTotal) != 0)
{ <span class="numberofresult">(Displaying @pageTotal out of @productTotal)</span>}
</h5>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment