Skip to content
Loading
  
  • class="col-8 pt-4">  
  • class="form-group row">  
  • class="col-4">  
  • for="Proposal.ProposalReference">  
  •   
  • class="col-8">  
  • for="Proposal.ProposalReference" class="form-control" />  
  • for="Proposal.ProposalReference" class="text-danger">  
  •   
  •   
  • class="form-group row">  
  • class="col-4">  
  • Category  
  •   
  • class="col-8">  
  • @Html.DropDownListFor(m => m.Proposal.ProposalCategoryId, Model.ProposalCategoryList, "--Select a Category--",  
  • new { @class = "form-control" })  
  • for="Proposal.ProposalCategoryId" class="text-danger">  
  •   
  •   
  • class="form-group row">  
  • class="col-4">  
  • for="Proposal.ProposalDate">  
  •   
  • class="col-8">  
  • for="Proposal.ProposalDate" class="form-control date-input" />  
  • for="Proposal.ProposalDate" class="text-danger">  
  •   
  •   
  • class="form-group row">  
  • class="col-8 offset-4">  
  • @if (Model.Proposal.ProposalId != 0)  
  • {  
  • "_EditAndBackToListButton" model="Model.Proposal.ProposalId" />  
  • }  
  • else  
  • {  
  • "_CreateAndBackToListButton" />  
  • }  
  •   
  •   
  •   
  •   
  • }  
  • }  
  • return View(proposalVM);  
  • }  
  • +2
  • Nicholas Mabe
    +2
    Hi Sachin, thank you for you help. It didn't quite work but helped point me in the right direction. My operators where incorrect. Both the following examples now filter:
     
    ProposalCategoryList = _unitOfWork.ProposalCategory.GetAll().OrderBy(s => s.ProposalCategoryName).Where(s => s.ProposalCategoryName == "Freight").Select(i => new SelectListItem
    ProposalCategoryList = _unitOfWork.ProposalCategory.GetAll().OrderBy(s => s.ProposalCategoryName).Where(ProposalCategory => ProposalCategory.ProposalCategoryId == 29).Select(i => new SelectListItem
    +2
  • Nikunj Satasiya
    +1
    Hi Nicholas, Please try this solution.
     
    But Before Implement, this solution checks the following points first.
     
    1) _unitOfWork.ProposalCategory.GetAll() return value or returnig null value?
    2) proposalVM.ProposalCategoryList is IEnumerable ?
     
    Solution
    1. proposalVM.ProposalCategoryList =   
    2. (from txt in _unitOfWork.ProposalCategory.GetAll().Where(s => s.ProposalCategoryName != "Freight").OrderBy(s => s.ProposalCategoryName).AsEnumerable()  
    3.     select new SelectListItem()  
    4.     {  
    5.         Text = txt.Description,  
    6.         Value = txt.Id.ToString()  
    7. });  
     Thank you.
    +1