Click here to Skip to main content
15,891,749 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have model Named as AddNoteViewModel and in this model I am creating a List of notetypes
  /// <summary>
 /// Gets or sets note value
 /// </summary>
 [DataMember(Name = "NoteType")]
 public string NoteType { get; set; }



public class Notetypes
{
     public int Id { get; set; }
     public String Name { get; set; }
}
  /// <summary>
 /// Gets or sets note types value
 /// </summary>
[DataMember(Name = "NoteTypes")]
public List<Notetypes> noteTypes { get; set; }

And in the Views I want to FilldropDown of notetypes
HTML
@Html.DropDownListFor(m => m.NoteType,Model.noteTypes)

Can anyone suggest me what is wrong here in this code.
Posted

1 solution

Using @html.DropDownList with Viewbag
C#
@Html.DropDownList("Mobiledropdown2", ViewBag.VBMobileList as SelectList)  
<pre></pre> 


Using @html.DropDownListFor With Model
C#
@Html.DropDownListFor(M => M.MobileList, new SelectList(Model.MobileList,"Value", "Text"))
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900