Ticket T204240
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

UpdateModel throws exception when using a DevExpress Combobox

GridView - "The model of type 'WebApplication1.Usuario' could not be updated."

created 10 years ago

Good Morning,

Over a MVC design pattern generated by visual studio 2013 I added a Grid of Dev. When testing the crud inclusion, exclusion and selection are operating normally. But the change is generating an exception.

The exception occurs in the "this.UpdateModel (ModelItem);" in action "public ActionResult GridViewPartialUpdate" in control "UsersController".
The exception message is "The model of type 'WebApplication1.Usuario' could not be updated.", Where then he unduly criticized some table fields "users" used as an example.

I am attaching the project without the folder "WebApplication1 / bin" and without the "packages" folder. I am also sending a picture exemplicando from the time the update click to the generation of exception and undue criticism. The table creation script is also attached.

I thank the help.

Answers approved by DevExpress Support

created 10 years ago (modified 10 years ago)

Hi Jeison,

So that the post data of our controls is applied properly, our DevExpressEditorsBinder should be used. The UpdateModel method does not use a binder specified in the ModelBinder attribute of an action method. It's necessary to specify it as the default binder. See the UpdateModel throws exception when using a DevExpress Combobox ticket.

C#
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); ModelBinders.Binders.DefaultBinder = new DevExpressEditorsBinder(); }

If you don't want this, you can get new values from the "item" parameter of the GridViewPartialUpdate action method:

C#
modelItem.LoginUsuario = item.LoginUsuario; modelItem.Nome = item.Nome; modelItem.Email = item.Email; modelItem.Ativo = item.Ativo;

I've updated your project to illustrate both approaches.

    Comments (2)
    JR JR
    Jeison Rodrigues 1 10 years ago

      Thanks for the feedback,
      It really is was the solution. Highlight once again the quality and speed of the support Dev.

        thank you. It's work for me.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.