When i put a break point on Index method and after executing the line _model.SubCategoryList.Add(new SelectListItem { Text = "Select Any ", Value = "0" });
, I'm getting below error.
An exception of type 'System.NullReferenceException' occurred in Proj.Web.dll but was not handled in user code
Additional information: Object reference not set to an instance of an object.
public ActionResult Index()
{
_model = new FA_AssetCreationModel { };
_model.SubCategoryList.Add(new SelectListItem { Text = "Select Any ", Value = "0" });
return View("Creation", _model);
}
I need to set a default value for the dropdownlist on page load inorder to avoid another error Value cannot be null. Parameter name: items
.