Hi I am new to MVC and even asp..
I want to create a form in MVC. With the help of some examples I am able to create TextBoxes, but I now I don\'t understand how to
Designing You Model:
Public class ModelName
{
...// Properties
public IEnumerable ListName { get; set; }
}
Prepare and bind List to Model in Controller :
public ActionResult Index(ModelName model)
{
var items = // Your List of data
model.ListName = items.Select(x=> new SelectListItem() {
Text = x.prop,
Value = x.prop2
});
}
In You View :
@Html.DropDownListFor(m => Model.prop2,Model.ListName)