Ejemplo:
public class ImpresorasViewModel
{
public List<ImpresoraViewModel> ListaImpresoras {get; set; }
public ImpresoraViewModel Impresora { get; set; }
public ImpresorasViewModel()
{
this.ListaImpresoras = new List<ImpresoraViewModel>();
this.Impresora = new ImpresoraViewModel();
}
}
Si el ActionResult esta definido así:
[HttpPost]
public ActionResult AgregarImpresora(ImpresorasViewModel impresora)
Esto falla, porque esta intentando recibir un parametro llamado impresora, mientras que en el modelo ya hay un parametro que se llama impresora.
Cambiandolo asi, queda funcionando:
[HttpPost]
public ActionResult AgregarImpresora(ImpresorasViewModel modelo)
Your model has a property named
Asmenys_info and the parameter in your POST method is also named asmenys_info. Internally the DefaultModelBinder reads the values of the form data which includes a value for Asmenys_info and attempts to set property Asmenys_info to that value but it fails because there is no conversion from a string to a complex object.
Change the name of the parameter to anything other than a name of a property in your model and it will bind fine, for example
[HttpPost]
public ActionResult Index(AsmenysInfoViewModel2 model)
No hay comentarios:
Publicar un comentario