Created
February 17, 2018 13:27
-
-
Save joshi-kumar/0dd05ea6d911073b3cafd1b60848d543 to your computer and use it in GitHub Desktop.
Pass viewbag value from view to partial view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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