I have a model called Project, which has the following properties (simplified for brevity).
[DataContract (IsReference = true)] Public Sector Project {[Key] [Database] Public Int ID {Receive; Set; } [Datamember] public string name {get; Set; } [DateMaker] Time of Public Date {Received; Set; }} This model is also a datacontent for the Dascost service which uses the unit framework 4 for a datastore query. The model is generated by the code template which automatically creates the CRUD service level against the unit framework model.
Now, in my MVC2 application there is a view to edit a field, the controllers have accepted the original version as argument on POST to the whole model.
[http post] Edit Public Action Result (Project Project) {var context = new ServiceContext (); Try {if (ModelState.IsValid) {project = context.UpdateProject (project); Return Redirect Action ("Index"); }} Catch {ModelState.AddModelError ("", "Could not Save Project"); } View return (project); } Now, my problem is that when the form is posted on the controller, except for for the 'id' property in all its areas in the project model population, which is omitted for 0. I've digged something and have petitioned Google to answer Uncle, but I could find the following in the closest fine model's class,
< Code> [Bine (include = "id")] which works fine, but only 'ID' populates the property, which means that I'm going to have every property clear Must specify the model included in the binding, of course, it can be dirty Especially since the many have been shown in the model I The way?
The intestine feels that the [key] feature has something in it, but I can not understand anything.
This form has a hidden input 'ID' property
<%: HTML.HiddenFor (model => model.id)%>
Try adding additional hidden fields for ID <%: Html.HiddenFor (model = & gt; Model.id)%>
Comments
Post a Comment