title: Input string was not in a correct format
body: <p>I need some help with the error shown in the title, my code for this is shown below.
  The error is appearing on this line:</p>
  
  <pre><code>@Html.EditorForModel()
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>@model Assignment2.Models.Order
  
  @{
      ViewBag.Title = "Address And Payment";
  } 
  
  
  
  &lt;script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"&gt;&lt;/script&gt;
  
  @using (Html.BeginForm())
  {
  
      &lt;h2&gt;Address And Payment&lt;/h2&gt;
      &lt;fieldset&gt;
          &lt;legend&gt;Shipping Information&lt;/legend&gt;
  
          @Html.EditorForModel()
      &lt;/fieldset&gt; 
      &lt;fieldset&gt;
          &lt;legend&gt;Payment&lt;/legend&gt;
          &lt;p&gt;We're running a promotion: all tickets free with the promo code: "FREE"&lt;/p&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.Label("Promo Code")
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.TextBox("PromoCode")
          &lt;/div&gt;
      &lt;/fieldset&gt;
  
  &lt;input type="submit" value="Submit Order" /&gt;
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using Assignment2.Models;
  
  namespace Assignment2.Controllers
  {
      [Authorize]
      public class CheckoutController : Controller
      {
          TicketBookingEntities storeDB = new TicketBookingEntities();
          const string PromoCode = "FREE";
  
          //
          // GET: /Checkout/AddressAndPayment
  
          public ActionResult AddressAndPayment()
          {
              return View();
          }
  
          //
          // POST: /Checkout/AddressAndPayment
          [HttpPost]
          public ActionResult AddressAndPayment(FormCollection values)
          {
              var order = new Order();
              TryUpdateModel(order);
  
              try
              {
                  if (string.Equals(values["PromoCode"], PromoCode,
                      StringComparison.OrdinalIgnoreCase) == false)
                  {
                      return View(order);
                  }
  
                  else
                  {
                      order.Username = User.Identity.Name;
                      order.OrderDate = DateTime.Now;
  
                      //Save Order
                      storeDB.Orders.Add(order);
                      storeDB.SaveChanges();
  
                      //Process the order
                      var cart = ShoppingCart.GetCart(this.HttpContext);
                      cart.CreateOrder(order);
  
                      return RedirectToAction("Complete",
                          new { id = order.OrderId });
                  }
              }
  
              catch
              {
                  //Invalid - redisplay with errors
                  return View(order);
  
              }
          }
  
          //
          // GET: /Checkout/Complete
          public ActionResult Complete(int id)
          {
              // Validate customer owns this order
              bool isValid = storeDB.Orders.Any(
                  o =&gt; o.OrderId == id &amp;&amp;
                  o.Username == User.Identity.Name);
              if (isValid)
              {
                  return View(id);
              }
              else
              {
                  return View("Error");
              }
          }
      }
  }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>@model Assignment2.ViewModels.ShoppingCartViewModel
  
  @{
      ViewBag.Title = "Shopping Cart";
  }
  
  &lt;script src="/Scripts/jquery-1.4.4.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      $(function () {
          // Document.ready -&gt; link up remove event handler
          $(".RemoveLink").click(function () {
              // Get the id from the link
              var recordToDelete = $(this).attr("data-id");
  
              if (recordToDelete != '') {
  
                  // Perform the ajax post
                  $.post("/ShoppingCart/RemoveFromCart", { "id": recordToDelete },
                      function (data) {
                          // Successful requests get here
                          // Update the page elements
                          if (data.ItemCount == 0) {
                               $('#row-' + data.DeleteId).fadeOut('slow');
                          } else {
                               $('#item-count-' + data.DeleteId).text(data.ItemCount);
                           }
  
                          $('#cart-total').text(data.CartTotal);
                          $('#update-message').text(data.Message);
                          $('#cart-status').text('Cart (' + data.CartCount + ')');
                      });
              }
          });
          });
  
      function handleUpdate() {
          // Load and deserialize the returned JSON data
          var json = context.get_data();
          var data = Sys.Serialization.JavaScriptSerializer.deserialize(json);
          // Update the page elements
          if (data.ItemCount == 0) {
              $('#row-' + data.DeleteId).fadeOut('slow');
          } else {
              $('#item-count-' + data.DeleteId).text(data.ItemCount);
          }
          $('#cart-total').text(data.CartTotal);
          $('#update-message').text(data.Message);
          $('#cart-status').text('Cart (' + data.CartCount + ')');
      }
  &lt;/script&gt;
  &lt;h3&gt;
      &lt;em&gt;Review&lt;/em&gt; your cart:
  &lt;/h3&gt;
  &lt;p class="button"&gt;
      @Html.ActionLink("Checkout &gt;&gt;", "AddressAndPayment", "Checkout")
  &lt;/p&gt;
  &lt;div id="update-message"&gt;
  &lt;/div&gt;
  &lt;table&gt;
      &lt;tr&gt;
          &lt;th&gt;
              Production Name
          &lt;/th&gt;
          &lt;th&gt;
              Price (each)
          &lt;/th&gt;
          &lt;th&gt;
              Quantity
          &lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
  &lt;/tr&gt; 
  @foreach (var item in Model.CartItems)
  { 
      &lt;tr id="row-@item.RecordId"&gt;
          &lt;td&gt;
              @Html.ActionLink(item.Performance.Title, "Details", "Store", new { id = item.PerformanceId }, null)
          &lt;/td&gt;
          &lt;td&gt;
               @item.Performance.Price
          &lt;/td&gt;
          &lt;td id="item-count-@item.RecordId"&gt;
               @item.Count
          &lt;/td&gt;
          &lt;td&gt;
              &lt;a href="#" class="RemoveLink" data-id="@item.RecordId"&gt;Remove from cart&lt;/a&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  }
      &lt;tr&gt;
          &lt;td&gt;
              Total
          &lt;/td&gt;
          &lt;td&gt;
          &lt;/td&gt;
          &lt;td&gt;
          &lt;/td&gt;
          &lt;td id="cart-total"&gt;
              @Model.CartTotal
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Stack Trace:</p>
  
  <pre><code>[FormatException: Input string was not in a correct format.]
     System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args) +9358943
     System.String.Format(IFormatProvider provider, String format, Object[] args) +107
     System.ComponentModel.DataAnnotations.ValidationAttribute.FormatErrorMessage(String name) +76
     System.Web.Mvc.DataAnnotationsModelValidator.get_ErrorMessage() +30
     System.Web.Mvc.RequiredAttributeAdapter.GetClientValidationRules() +45
     System.Web.Mvc.HtmlHelper.&lt;.ctor&gt;b__1(ModelValidator v) +10
     System.Linq.&lt;SelectManyIterator&gt;d__14`2.MoveNext() +238
     System.Web.Mvc.HtmlHelper.GetUnobtrusiveValidationAttributes(String name, ModelMetadata metadata) +632
     System.Web.Mvc.Html.InputExtensions.InputHelper(HtmlHelper htmlHelper, InputType inputType, ModelMetadata metadata, String name, Object value, Boolean useViewData, Boolean isChecked, Boolean setId, Boolean isExplicitValue, IDictionary`2 htmlAttributes) +807
     System.Web.Mvc.Html.DefaultEditorTemplates.StringTemplate(HtmlHelper html) +135
     System.Web.Mvc.Html.ActionCacheCodeItem.Execute(HtmlHelper html, ViewDataDictionary viewData) +30
     System.Web.Mvc.Html.TemplateHelpers.ExecuteTemplate(HtmlHelper html, ViewDataDictionary viewData, String templateName, DataBoundControlMode mode, GetViewNamesDelegate getViewNames, GetDefaultActionsDelegate getDefaultActions) +330
     System.Web.Mvc.Html.TemplateHelpers.TemplateHelper(HtmlHelper html, ModelMetadata metadata, String htmlFieldName, String templateName, DataBoundControlMode mode, Object additionalViewData, ExecuteTemplateDelegate executeTemplate) +1117
     System.Web.Mvc.Html.TemplateHelpers.TemplateHelper(HtmlHelper html, ModelMetadata metadata, String htmlFieldName, String templateName, DataBoundControlMode mode, Object additionalViewData) +66
     System.Web.Mvc.Html.DefaultEditorTemplates.ObjectTemplate(HtmlHelper html, TemplateHelperDelegate templateHelper) +575
     System.Web.Mvc.Html.DefaultEditorTemplates.ObjectTemplate(HtmlHelper html) +47
     System.Web.Mvc.Html.TemplateHelpers.ExecuteTemplate(HtmlHelper html, ViewDataDictionary viewData, String templateName, DataBoundControlMode mode, GetViewNamesDelegate getViewNames, GetDefaultActionsDelegate getDefaultActions) +714
     System.Web.Mvc.Html.TemplateHelpers.TemplateHelper(HtmlHelper html, ModelMetadata metadata, String htmlFieldName, String templateName, DataBoundControlMode mode, Object additionalViewData, ExecuteTemplateDelegate executeTemplate) +1117
     System.Web.Mvc.Html.TemplateHelpers.TemplateHelper(HtmlHelper html, ModelMetadata metadata, String htmlFieldName, String templateName, DataBoundControlMode mode, Object additionalViewData) +66
     System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper html) +60
     ASP._Page_Views_Checkout_AddressAndPayment_cshtml.Execute() in c:\Users\Ian\Desktop\Assignment2\Assignment2\Assignment2\Views\Checkout\AddressAndPayment.cshtml:19
     System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +207
     System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81
     System.Web.WebPages.StartPage.RunPage() +19
     System.Web.WebPages.StartPage.ExecutePageHierarchy() +65
     System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +76
     System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +220
     System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
     System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +303
     System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
     System.Web.Mvc.&lt;&gt;c__DisplayClass1c.&lt;InvokeActionResultWithFilters&gt;b__19() +23
     System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260
     System.Web.Mvc.&lt;&gt;c__DisplayClass1e.&lt;InvokeActionResultWithFilters&gt;b__1b() +19
     System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
     System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
     System.Web.Mvc.Controller.ExecuteCore() +116
     System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
     System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
     System.Web.Mvc.&lt;&gt;c__DisplayClassb.&lt;BeginProcessRequest&gt;b__5() +37
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass1.&lt;MakeVoidDelegate&gt;b__0() +21
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass8`1.&lt;BeginSynchronous&gt;b__7(IAsyncResult _) +12
     System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
     System.Web.Mvc.&lt;&gt;c__DisplayClasse.&lt;EndProcessRequest&gt;b__d() +50
     System.Web.Mvc.SecurityUtil.&lt;GetCallInAppTrustThunk&gt;b__0(Action f) +7
     System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
     System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
     System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
     System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8970061
     System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +184
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.ComponentModel;
  using System.ComponentModel.DataAnnotations;
  using System.Web.Mvc;
  
  
  namespace Assignment2.Models
  {
      [Bind(Exclude = "OrderId")]
      public partial class Order
      {
          [ScaffoldColumn(false)]
          public int OrderId { get; set; }
  
          [ScaffoldColumn(false)]
          public System.DateTime OrderDate { get; set; }
  
          [ScaffoldColumn(false)]
          public string Username { get; set; }
  
          [Required(ErrorMessage = "First Name is required")]
          [DisplayName("First Name")]
          [StringLength(160)]
          public string FirstName { get; set; }
  
          [Required(ErrorMessage = "Last Name is required")]
          [DisplayName("Last Name")]
          [StringLength(160)]
          public string LastName { get; set; }
  
          [Required(ErrorMessage = "Please enter Address")]
          [StringLength(70)]
          public string Address { get; set; }
  
          [Required(ErrorMessage = "Please enter City")]
          [StringLength(40)]
          public string City { get; set; }
  
          [Required(ErrorMessage = "Please enter County")]
          [StringLength(40)]
          public string County { get; set; }
  
          [Required(ErrorMessage = "Please enter {Postal Code")]
          [DisplayName("Postal Code")]
          [StringLength(10)]
          public string PostalCode { get; set; }
  
          [Required(ErrorMessage = "Please enter Country")]
          [StringLength(40)]
          public string Country { get; set; }
  
          [Required(ErrorMessage = "Please enter Phone Number")]
          [StringLength(24)]
          public string Phone { get; set; }
  
          [Required(ErrorMessage = "Email Address is required")]
          [DisplayName("Email Address")]
          [RegularExpression(@"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}",
          ErrorMessage = "Email is is not valid.")]
          [DataType(DataType.EmailAddress)]
          public string Email { get; set; }
  
          [ScaffoldColumn(false)]
          public decimal Total { get; set; }
  
  
          public List&lt;OrderDetail&gt; OrderDetails { get; set; }
      }
  }
  </code></pre>
  
  <p>If you need any other information please let me know, thanks</p>