خرید بک لینک

Vote count: 0

I have a partial view

  if (CompanyFound != null)
{
    Products = DB.tblBuyOnlineMasters.Where(c => c.CompanyID == CompanyID).OrderByDescending(p => p.BuyOnlineID).ToList();
    if (Products.Count < 1)
    {
        ViewBag.Msg = "No products found for this company";
    }
}
else
{
    ViewBag.Msg = "Company Not Found (Showing result from all companies)";
}

I need to display the data in the main view

<div class="col-sm-8" style="background-color: rgb(231, 231, 231)">
    @{                  
        Html.RenderPartial("ProductRepeater");                  
    }             

        <h4 style="text-align: center;">
            @ViewBag.Msg
        </h4>                         
</div>

The ViewBag method is not transporting the data

asked 1 min ago

1 Answer

Vote count: 0

I was able to Carry the Data by substituting

ViewBag.Msg

By

TempData["Msg"] 

I want know if this is fine, or is there any other method in MVC

View looks like

<div class="col-sm-8" style="background-color: rgb(231, 231, 231)">
    @{                  
        Html.RenderPartial("ProductRepeater");                  
    }             
        <h4 style="text-align: center;">
            @TempData["Msg"]
        </h4>
</div>

answered 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 خرداد 1395 ساعت: 18:29

صفحه بندی