An exception of type 'System.ArgumentNullException' occurred in System.Web.Mvc.dll but was not handled in user code
-
Hi, I am using DropdownListFor in my MVC cshtml page, but I am getting the above error:
@Html.DropDownListFor(model => model.PKModeOfServiceLKPId, new SelectList(Model.ModeOfServiceLKPList, "PKModeOfServiceLKPId", "Description") , new { @class = "form-control input-sm", style = "width:300px;", @id = "idDDLForModeOfServiceCode"})
But I am getting the values in the Model as below;
public List GetMCMSSFCrosswalkList() { using (BHPRVEntities pe = new BHPRVEntities()) { var prov = pe.Usp\_Get\_MCMSSFCategoryCrosswalkList(); return prov.Select(p => new MCMSSFCrosswalk() { Id = p.Id, Description = p.MCMSSFCrosswalkDescription, MCModeOfServiceCode=p.ModeOfServiceCode, FKServFuncCatMCModeOfServiceId = p.FKServFuncCatMCModeOfServiceId, ModeOfServiceCode=p.ModeOfServiceCode, ServiceFunctionCategoryCode=p.ServiceFunctionCategoryCode, ServiceFunctionCategoryDescription=p.ServiceFunctionCategoryDescription, CreatedDate = ((p.CreatedDate != null) && (!DBNull.Value.Equals(p.CreatedDate))) ? p.CreatedDate : null, CreatedBy = p.CreatedBy, ModifiedDate = ((p.ModifiedDate != null) && (!DBNull.Value.Equals(p.ModifiedDate))) ? p.ModifiedDate : null, ModifiedBy = p.ModifiedBy, IsValid = ((p.IsValid == null) || (DBNull.Value.Equals(p.IsValid))) ? true : p.IsValid, ModeOfServiceLKPList=GetListOfModeOfServices(), MCModeOfServiceLKPList = GetListOfMCModeOfServices(), ServiceFunctionCategoryLKPList = GetListOfServiceFunctionCategories() }).ToList(); } }
My Model is as below:
public class MCMSSFCrosswalk { private List listOfModeOfServiceLKP = new List(); private List listOfMCModeOfServiceLKP = new List(); private List listOfServiceFunctionCategoryLKP = new List(); public int Id { get; set; } public string Description { get; set; } public string RevenueCode { get; set; } public string ProcedureCode { get; set; }
-
Hi, I am using DropdownListFor in my MVC cshtml page, but I am getting the above error:
@Html.DropDownListFor(model => model.PKModeOfServiceLKPId, new SelectList(Model.ModeOfServiceLKPList, "PKModeOfServiceLKPId", "Description") , new { @class = "form-control input-sm", style = "width:300px;", @id = "idDDLForModeOfServiceCode"})
But I am getting the values in the Model as below;
public List GetMCMSSFCrosswalkList() { using (BHPRVEntities pe = new BHPRVEntities()) { var prov = pe.Usp\_Get\_MCMSSFCategoryCrosswalkList(); return prov.Select(p => new MCMSSFCrosswalk() { Id = p.Id, Description = p.MCMSSFCrosswalkDescription, MCModeOfServiceCode=p.ModeOfServiceCode, FKServFuncCatMCModeOfServiceId = p.FKServFuncCatMCModeOfServiceId, ModeOfServiceCode=p.ModeOfServiceCode, ServiceFunctionCategoryCode=p.ServiceFunctionCategoryCode, ServiceFunctionCategoryDescription=p.ServiceFunctionCategoryDescription, CreatedDate = ((p.CreatedDate != null) && (!DBNull.Value.Equals(p.CreatedDate))) ? p.CreatedDate : null, CreatedBy = p.CreatedBy, ModifiedDate = ((p.ModifiedDate != null) && (!DBNull.Value.Equals(p.ModifiedDate))) ? p.ModifiedDate : null, ModifiedBy = p.ModifiedBy, IsValid = ((p.IsValid == null) || (DBNull.Value.Equals(p.IsValid))) ? true : p.IsValid, ModeOfServiceLKPList=GetListOfModeOfServices(), MCModeOfServiceLKPList = GetListOfMCModeOfServices(), ServiceFunctionCategoryLKPList = GetListOfServiceFunctionCategories() }).ToList(); } }
My Model is as below:
public class MCMSSFCrosswalk { private List listOfModeOfServiceLKP = new List(); private List listOfMCModeOfServiceLKP = new List(); private List listOfServiceFunctionCategoryLKP = new List(); public int Id { get; set; } public string Description { get; set; } public string RevenueCode { get; set; } public string ProcedureCode { get; set; }
If the breakpoint isn't getting hit, then you haven't called the method. What does the code in your action method look like?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer