title: Binding difficulty upon postback of list
body: <p>I am having the difficulty to post back the new data being entered.  It seems that the data sent to the view are sent back to the controller, despite changes made to the data before submit.</p>
  
  <p>My code is as follows:</p>
  
  <p>Controller
       public class GroupRateController : Controller
      {
          //
          // GET: /GroupRate/</p>
  
  <pre><code>    public ActionResult Index()
      {
          GroupRateModel model = new GroupRateModel();
          return View(model);
      }
  
      [HttpPost]
      public ActionResult Index(GroupRateModel model)
      {
          model.Save(model);
          return View(model);
      }
  
  }
  </code></pre>
  
  <p>View</p>
  
  <pre><code> @model MvcApplication1.Models.GroupRateModel
  
  @{
      View.Title = "Index";
      Layout = "~/Views/Shared/_Layout.cshtml";
  }
  
  &lt;h2&gt;Index&lt;/h2&gt;
  @using (Html.BeginForm())
  {
  
  @Html.ValidationSummary()
  
  &lt;table&gt;
  &lt;thead&gt;
  
  &lt;/thead&gt;
  &lt;tr&gt;&lt;th&gt;Rate Group&lt;/th&gt;&lt;th&gt;Default Amount&lt;/th&gt;&lt;th&gt;Client Amount&lt;/th&gt;&lt;/tr&gt;
  @foreach (var item in @Model.ClientRateDetails)
  {
  &lt;tr&gt;&lt;td&gt;@item.RateGroupName&lt;/td&gt;&lt;td align="right"&gt;@Html.DisplayFor(m =&gt; @item.RateGroupID)&lt;/td&gt;&lt;td&gt;@Html.EditorFor(model =&gt; item.ClientRate)&lt;/td&gt;&lt;/tr&gt;
  
  }
  &lt;/table&gt;
  
  &lt;p&gt; &lt;input type ="submit"  value="Save" id="submit" /&gt;&lt;/p&gt;
  }
  </code></pre>
  
  <p>Model</p>
  
  <pre><code>    using System.ComponentModel.DataAnnotations;
  
  namespace MvcApplication1.Models
  {
      public class GroupRateModel 
      {
          public List&lt;ClientRateDetailsModel&gt; ClientRateDetails = new List&lt;ClientRateDetailsModel&gt;() ;
          public string Name { get; set; }
  
  
          public GroupRateModel()
          {
                      ClientRateDetails.Add(new ClientRateDetailsModel
                      {
                          RateGroupID = 1,
                          RateGroupName = "Test1",
                          ClientRate = 100
                      });
  
                      ClientRateDetails.Add(new ClientRateDetailsModel
                      {
                          RateGroupID = 2,
                          RateGroupName = "Test2",
                          ClientRate = 200
                      });
  
                      ClientRateDetails.Add(new ClientRateDetailsModel
                      {
                          RateGroupID = 3,
                          RateGroupName = "Test3",
                          ClientRate = 300
                      });
  
          }
  
          public void Save(GroupRateModel model)
          {
               foreach (var item in model.ClientRateDetails)
                  {
                      //...;
                  }
              }
          }
  
  
      public class ClientRateDetailsModel
      {       
          [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:00.00}", NullDisplayText = "")]
          [Range(0, (double)decimal.MaxValue, ErrorMessage = "Please enter a valid rate")]
          public decimal? ClientRate { get; set; }
          public int? RateGroupID { get; set; }
          public string RateGroupName { get; set; }
      }
  </code></pre>
  
  <p>}</p>