I have an ajax grid using popup edit mode and kendo dropdownlists in the popup. On the post to the controller the dropdownlist value is not bound to the model property if the model property is a nullable int. If I use the regular mvc dropdownlist the value posts fine. I also have a kendo dropdownlist of states (text and value are both string) and that posts fine to the model property of string.
I am using the internal build from 8/31.
The Grid:
Model's editor template
The Model:
Controller:
public ActionResult Index()
{
SetupLists();
return View();
}
public ActionResult _Read([DataSourceRequest] DataSourceRequest request)
{
return Json(contactsService.Get().ToDataSourceResult(request));
}
[HttpPost]
public ActionResult _Create([DataSourceRequest] DataSourceRequest request, Contact contact)
{
if (ModelState.IsValid)
{
contact.LastUpdateBy = User.Identity.Name;
contactsService.Create(contact);
}
return Json(new[] { contact }.ToDataSourceResult(request, ModelState));
}
[HttpPost]
public ActionResult _Update([DataSourceRequest] DataSourceRequest request, Contact contact)
{
if (ModelState.IsValid)
{
contact.LastUpdateBy = User.Identity.Name;
contactsService.Update(contact);
}
return Json(new[] { contact }.ToDataSourceResult(request, ModelState));
}
private void SetupLists()
{
IList<
Lab
> labs = labsService.Get();
labs.Insert(0, new Lab { Description = "" });
IList<
Tier
> tiers = tiersService.Get();
tiers.Insert(0, new Tier { Description = "" });
IList<
Institution
> institutions = institutionsService.Get();
institutions.Insert(0, new Institution { Description = "" });
IList<
Contact
> contacts = contactsService.Get();
contacts.Insert(0, new Contact { FullName = "" });
IList<
Grant
> grants = grantsService.Get();
grants.Insert(0, new Grant { Description = "" });
IList<
State
> states = statesService.Get();
states.Insert(0, new State { Name = "" });
ViewBag.Labs = labs;
ViewBag.Tiers = tiers;
ViewBag.Institutions = institutions;
ViewBag.Contacts = contacts;
ViewBag.Grants = grants;
ViewBag.States = states;
}