title: Set Selected Value of @Html.DropDownList to Querystring value or not
body: <p>I have a typical Create Action that was generated by scaffolding in MVC 4. Nothing fancy.
  Normally I get to this page by the following URL <code>/RecipeLines/Create</code> and when I create that specific record I have a dropdown list I have altered to receive recipeID if sent:</p>
  
  <pre><code>    &lt;div class="editor-label"&gt;
          @Html.LabelFor(model =&gt; model.RecipeID, "Recipe")
      &lt;/div&gt;
      &lt;div class="editor-field"&gt;
          @Html.DropDownList("RecipeID", (SelectList)ViewBag.RecipeID, string.Empty)
          @Html.ValidationMessageFor(model =&gt; model.RecipeID)
      &lt;/div&gt;
  </code></pre>
  
  <p>What I would like to do is link to the Create page by passing a recipeID, that would look something like this:</p>
  
  <p><code>/RecipeLines/Create/2</code></p>
  
  <p>I have edited the <code>@Html.DropDownList</code> to either accept a parameter and HOPEFULLY select the proper RecipeID or if it is linked to without the query string</p>
  
  <p><code>/RecipeLines/Create</code></p>
  
  <p>then it would not have a selected value.</p>
  
  <p>Here is my Create Action as is.</p>
  
  <pre><code>    // GET: /RecipeLines/Create
  
      public ActionResult Create(int? recipeID)
      {
          ViewBag.MeasurementID = new SelectList(db.Measurements, "MeasurementID", "MeasurementEn");
          ViewBag.RecipeID = new SelectList(db.Recipes, "RecipeID", "RecipeNameEn", recipeID);
          ViewBag.IngredientID = new SelectList(db.Ingredients, "IngredientID", "IngredientNameEn");
                  return View();
      }
  </code></pre>
  
  <p>My 2 @Html.ActionLink(s) looks like this:</p>
  
  <pre><code>    //Coming from the Recipe Page        
      @Html.ActionLink("+", "Create", "RecipeLines", new { recipeID = recipe.RecipeID }, null);
  
      //Coming from the RecipeLines/Index page
      @Html.ActionLink("Create New", "Create")
  </code></pre>
  
  <p><code>THIS PROBLEM HAS BEEN SOLVED AND THE ABOVE CODE NOW WORKS</code></p>