Reputation: 131
I have a view and am passing a view model to it in order to populate the strongly typed inputs. The view model is created just fine. I have debugged the controller to ensure that model is created properly and the properties of the view model are set with the correct values from the database (SQL Management Server 2008), which it is doing with no problem. When I pass the view model into the view, only some of the strongly typed inputs are populated and the others aren't. I've checked to make sure that I have all of the inputs are pointing to the correct model parameter. The form consists of 6 pages that I'm using Kendo UI TabStrip to keep the pages separate. The view model is fairly large so I'm wondering if that is a factor. The basic functionality is that a user can start filling out a form, save it to the db, retrieve what they have filled out, and then complete it at a later date. Here is some sample code:
Here is a code snippet of the view:
@model myWilmer.Models.QuoteViewModel
<section id="quoteEntry">
@Html.ValidationSummary(true)
@using (Html.BeginForm("CreateQuote", "Quotes", FormMethod.Post, new { id = "quotesForm" }))
{
@Html.TextBoxFor(m => m.QuoteNum, new { @class = "k-textbox", Value = "", id = "quoteNumber"})
}
Here is a snippet of the view model:
public class QuoteViewModel
{
public QuoteViewModel()
{
}
[Display(Name = "Quote Number:")]
[Required]
[RegularExpression(@"^[0-9]+$")]
public int QuoteNum { get; set; }
}
Here is a snippet of the controller:
[HttpGet]
public ActionResult Edit(int id)
{
QuoteViewModel qvm;
//...Creating ViewModel
return View(qvm);
}
Upvotes: 0
Views: 66
Reputation: 10839
You are overriding the Value by having Value = "". Remove that and it should work.
@Html.TextBoxFor(m => m.QuoteNum, new { @class = "k-textbox", id = "quoteNumber"})
Upvotes: 1