c# - Error in ASP.NET MVC SelectList. Value Cannot be null, parameter name: items -


The line I is causing some problems in the development of an MVC app

  & lt;% = Html.DropDownListFor (model = & gt; model.TypeID, new selectList ((IEnumerable) ViewData [ "TaskingTypes"], "TypeID", "TypeName"))% & gt;  

If this form does not fill two other required fields, then the error causes the title. When the fields are filled up, the form is stored and recorded, there is no problem in the DB. Anyone have any idea why the verification is being raised and moved to the scene?

'TaskingTypes' one unit has 1 relationship for many relationships with the 'tasking' institution. 'Tasking' foreign key 'TypeID' in

stack trace of the top 2 lines:

  [ArgumentNullException: Value can not be null. [Parameter name: item] System.Web.Mvc.MultiSelectList..ctor (IEnumerable items, string dataValueField, string dataTextField, IEnumerable selectedValues) 262,322 System.Web.Mvc.SelectList..ctor (IEnumerable items, string dataValueField, string dataTextField) +31  

this controller

  [AcceptVerbs (HttpVerbs.Get), authorized] public ActionResult Create () {tasking tasking = new tasking () { Created_On = DateTime.Now}; SeeData ["TaskingTaps"] = tt.GetAllTaskingTypes (). ToList (); See Return (Working); } [AcceptVerbs (HttpVerbs.Post), authorized] public ActionResult (Tasking Tasking) Create {if (TryUpdateModel (multitasking)) {tasking.Created_On = DateTime.Now; working. Crazy_wow = user Identity; name; TaskingRepository.Add (tasking); TaskingRepository.Save (); Return Redirect Action ("Details", New {id = Working. Tasking ID}); } See Return (Working); }  

and this is the validation class Tasking_Validation {[Required (error message) "Select the type of work")] Public String TypeID {Received; Set; } [Required (Error Message = "Tasking Title Required")] [String Lang (255, Error Message = "Title Can not Expire 255 Characters")] Public String Title {get; Set; } [Required (Error Message = "Location Required")] [String Lang (255, Error Message = "Place Can not Exceed 50 Characters")] Public String Location {get; Set; }}

Many thanks for watching

Required line:

 See  data ["taskingtaps"] = tt.GetAllTaskingTypes (). ToList (); See also  

in your post method, if there is a validation error, then you should fix your problem.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -