Jun 04, 2013, 6:56 PM
[CLOSED] MVC How to load combobox via ViewBag?
Hi,
Like in question how to load combobox with items (Ext.Net.ListItem)
I tryed to do this:
controller
This approach work just fine but please see my second post for better understanding this question.
How should I load this combobox with items or how is best approach to load combobox items(created in controller method) Is there a object which work similar to SelectList?
Thanks,
ViDom
Like in question how to load combobox with items (Ext.Net.ListItem)
I tryed to do this:
controller
public ActionResult Create()
{
ViewBag.Type = new List<Ext.Net.ListItem> { new Ext.Net.ListItem("Odbiorca", 1), new Ext.Net.ListItem("Dostawca", 2), new Ext.Net.ListItem("Odbiorca / Dostawca", 4) };
return View();
}
create.cshtml@{
List<Ext.Net.ListItem> listType = (List<Ext.Net.ListItem>)ViewBag.Type;
}
....
Html.X().ComboBoxFor(m=>m.Type).Editable(false)
.ForceSelection(true).EmptyText("-- choose--").EmptyValue(0)
.Items(listType)
....
Edited:This approach work just fine but please see my second post for better understanding this question.
How should I load this combobox with items or how is best approach to load combobox items(created in controller method) Is there a object which work similar to SelectList?
Thanks,
ViDom
Last edited by Daniil; Jun 11, 2013 at 4:26 AM.
Reason: [CLOSED]