title: Passing Querystring value into View Model
body: <p>i have a parent child situation with for example my user class and my userwork child class (Entity framework scaffolded classes). i used the controller wizard to scaffold CRUD methods and views. it scaffolded two  Create method's, the Get and the httpPost methods.</p>
  
  <p>In a normal scenario i would want to be passing in the user's id into the get so that it would be passed into the model which is being populated in html.beginform() section and then it would subsequently be passed into thepost.</p>
  
  <p>I am unsure what is the correct method to do this?  I have modified the Get as below</p>
  
  <pre><code>public ActionResult Create(int id)
   {
       this.ViewData.Add("id", id);
       return View();
   }
  </code></pre>
  
  <p>and the Create.shtml as below</p>
  
  <pre><code>@model UserWork
  
  @{
      ViewBag.Title = "Create";
      int id = (int)ViewData["id"];
  }
  
  &lt;h2&gt;Create&lt;/h2&gt;
  &lt;script src="@Url.Content("~/Scripts/jquery.validate.min.js")"&gt;&lt;/script&gt;
  &lt;script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"&gt;&lt;/script&gt;
  
  @using (Html.BeginForm(routeValues:new {user_id = @id})) {
      @Html.ValidationSummary(true)
  
      &lt;fieldset&gt;
          &lt;legend&gt;Userwork&lt;/legend&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.user_id)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.user_id)
              @Html.ValidationMessageFor(model =&gt; model.user_id)
          &lt;/div&gt;
  ......
  </code></pre>
  
  <p>(i left the scaffolded user_id fields as editable so i could test seeing them prepopulated when the form loads) which the form loads it doesnt have my id value in the fields, Is this the correct method of achieving this?</p>
  
  <p>Cheers
  Tim</p>