2016-06-18 5 views
0

私はMVCのパスメッセージは

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)"; 
} 

は私が

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

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

がViewBag方法は、データを転送されていないメインビューでデータを表示する必要がある部分図を持って表示する

答えて

0

私はデータを代入してキャリーすることができました

ViewBag.Msg 
私は、これは結構です、またはMVC

の他の方法

ビューが

<div class="col-sm-8" style="background-color: rgb(231, 231, 231)"> 
    @{     
     Html.RenderPartial("ProductRepeater");     
    }    
     <h4 style="text-align: center;"> 
      @TempData["Msg"] 
     </h4> 
</div> 
のように見えるがあるかどうかを知りたい

TempData["Msg"] 

によって