Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

System.NullReferenceException: 'Object reference not set to an instance of an object.'

$
0
0

My view

<div class="form-group"><div class="row"><div class="col-sm-2"><label asp-for="Locations">Locations</label></div><div class="col-4">
                @Html.DropDownListFor(m => m.WeatherLocation.LocationId, Model.Locations, "-Select a Location",
                new { @class = "form-control" })</div></div></div>

Model

public class WeatherVM
    {
       // public int LocationId { get; set; }
        public DateTime ForcastDate { get; set; }
        public WeatherLocation WeatherLocation;
        public IEnumerable<Weather> Weather { get; set; }
        public IEnumerable<SelectListItem> Locations { get; set; }

    }
}
public class WeatherLocation
    {
        [Key]
        public int LocationId { get; set; }
        [Required]
        public string LocationName { get; set; }
        [Required]
        public string Woeid { get; set; }
    }

Location table

id           Name    Woeid

1          EKM           asdsds

2         PPP              asdsad

I want to bring the dropdown in location please help


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>