Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. An exception of type 'System.ArgumentNullException' occurred in System.Web.Mvc.dll but was not handled in user code

An exception of type 'System.ArgumentNullException' occurred in System.Web.Mvc.dll but was not handled in user code

Scheduled Pinned Locked Moved ASP.NET
htmlasp-netarchitecturehelpquestion
2 Posts 2 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    indian143
    wrote on last edited by
    #1

    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; }
    
    Richard DeemingR 1 Reply Last reply
    0
    • I indian143

      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; }
      
      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      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

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups