Abhilash J A

Abhilash J A

  • 531
  • 2.4k
  • 598.3k

error - if list is zero checking in View, MVC.

Mar 13 2017 12:48 AM
Hello everyone,
 
I'm working on MVC 5, there is a viewmodel class and contain a static list as the same class.
 
  1. public class PartnerProjectVM  
  2.     {  
  3.         public int idPartnerProject { getset; }  
  4.         public string ProjectName { getset; }  
  5.         public string ProjectDescription { getset; }  
  6.   public static List<PartnerProjectVM> listPartnerProjectVM = new List<PartnerProjectVM>();  

 In view,
 
How can I check
 
  1. @model Reboxwebapp.Models.ViewModel.PartnerProjectVM  
  2.   @if (listPartnerProjectVM.Count() != null)  
  3.                             {  
  4.                                 <div class="col-sm-3">  
  5.                                     <div>  
  6.                                         <a class="list-group-item active left-menu-head">Projects List</a>  
  7.                                         @foreach (var item in listPartnerProjectVM)  
  8.                                         {  
  9.                                             <a href="#" id="idProject" class="list-group-item" name="@item.idPartnerProject">@item.ProjectName</a>  
  10.                                         }  
  11.   
  12.                                     </div>  
  13.                                 </div>  
  14.                             } 
Here error occurred. please help me... 

Answers (6)