Skip to content

Passing data from controller to view is showing NAN value

sangeetha k

Asked Apr 30, 2018, 12:51 AM EDT2 answers
Share
LinkedInX
i wish to fetch the count of the row in table using which i wish to restrict the display of the panel inside the page using jquery .
here goes the #dal layer code
  1. int LoanId;  
  2. using (TempoDevRM01Entities borrowerDBEntity = new TempoDevRM01Entities())  
  3. {  
  4. LoanId = borrowerDBEntity.ReferralDetails.Where(x => x.LoanNo == LoanNo).Select(x => x.LoanID).FirstOrDefault();  
  5. //LoanId= GetLoanId(LoanNo);  
  6. int hardshipcount=borrowerDBEntity.HardshipDiscoveries.Where(x=>x.LoanID==LoanId).Select(x=>x.HardshipDiscoveryID).Count();  
  7. return hardshipcount;  
  8. }  
#view code
  1. var hardshipid =parseInt( @ViewBag.HardshipCount);  
  2. if (hardshipid < 1) {  
  3. debugger;  
  4. $("#panel3").attr("disabled", "disabled");  
  5. $("#panel3").css('cursor', 'not-allowed');  
  6. }  
  7. else {  
  8. $("#reviewsubmit").removeAttr("disabled");  
  9. $("#panel3").css('cursor', 'POINTER');  
  10. }  
but it shows NAN value in locals is anythigng wrong with these things?

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • +1
    before return write viewbag.HrdshipCount=hardshipcount then write return statement
    +1
  • 0
    sorry i have done that in the controller part
    int hardshipCount = repository.DocumentPanelfilter(LoanID);
    ViewBag.HardshipCount = (hardshipCount);
     
    0