I'm using the popup editing mode with a custom MVC template for editing, having just created an EditorTemplate with the name of my model. Within this template I have two DropDownLists, both bound using a similar method; each have a custom template and these are specified by way of UIHint metadata on my model properties. All this works fine for edits; the DDL values are posted back correctly, and I even see the background grid change dynamically as I change the values before doing the Update.
However, inserts don't work. The same edit template appears and the text fields update the background grid dynamically, but the DDLs don't. When posted back, the ID values don't have the ID values from the DDLs, but the text values. This of course causes validation to fail.
Edit: Sample project attached. Ignore the fact that the two DDL values don't show in the grid initially; they do in the full solution so I've just missed something here. But if you edit an item and select values from the two DDLs, that's fine. Not so with the Create.
Side question: when using the same template for Edit/Create can we change the title of the popup window?
Edit 2: Ok, more investigation this morning, after hacking a workaround. It looks like the request form variables come back different between Edit and Create, even though they use the same editor. I'm currently seeing the following in Request.Form:
DefaultWorkPoolId.Id
DefaultWorkPoolId.Name
DefaultWorkPoolId[Id]
DefaultWorkPoolId[Name]
Clearly the model binding can't bind these to the property, which is DefaultWorkPoolId, but the question is why the Create behaviour is different. It would be good to get an answer on this so I can remove the hacked code; this is only the first screenof many and I don't want to have to repeat this everywhere.
However, inserts don't work. The same edit template appears and the text fields update the background grid dynamically, but the DDLs don't. When posted back, the ID values don't have the ID values from the DDLs, but the text values. This of course causes validation to fail.
Edit: Sample project attached. Ignore the fact that the two DDL values don't show in the grid initially; they do in the full solution so I've just missed something here. But if you edit an item and select values from the two DDLs, that's fine. Not so with the Create.
Side question: when using the same template for Edit/Create can we change the title of the popup window?
Edit 2: Ok, more investigation this morning, after hacking a workaround. It looks like the request form variables come back different between Edit and Create, even though they use the same editor. I'm currently seeing the following in Request.Form:
DefaultWorkPoolId.Id
DefaultWorkPoolId.Name
DefaultWorkPoolId[Id]
DefaultWorkPoolId[Name]
Clearly the model binding can't bind these to the property, which is DefaultWorkPoolId, but the question is why the Create behaviour is different. It would be good to get an answer on this so I can remove the hacked code; this is only the first screenof many and I don't want to have to repeat this everywhere.