Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It looks to me like you have a Transfer object which has a Veteran property on it and this is what you are trying to edit? Correct me if I got this all wrong..</p> <p>Firstly I would strongly type your views and controls.</p> <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage&lt;Transfer&gt;" %&gt; </code></pre> <p>Im assuming the type of Veteran is Veteran, it may be person or something else I don't know. Once you have this you can remove the var Model.Transfer etc.</p> <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;Veteran&gt;" %&gt; &lt;% var thisTransfer = Model.Transfer; var thisVeteran = thisTransfer.Veteran; %&gt; </code></pre> <p>Then I would alter your edit page to be </p> <pre><code>&lt;% Html.RenderPartial("TransferForm", Model.Veteran); %&gt; </code></pre> <p>As you have bound to a Transfer object but the form is returning data for a Veteran object your names in the user control would need to be named </p> <pre><code>&lt;%= Html.TextBox("collection.Veteran.AdmitDX", Model.AdmitDX)%&gt; </code></pre> <p>In order to bind correctly I believe you can use the <code>Bind(Prefix="")</code> attribute to override the binder prefix which by default looks at the name of the property on your action method, in this case "collection".</p> <p>You could also leave the names without the "Veteran" prefix and instead bind to a Veteran object directly.</p> <pre><code>[AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(int id,[Bind(Prefix="")]Veteran veteran) { </code></pre> <p>Hope this helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload