title: Passing value from Controller to View in MVC
body: <p>I have a view that was generated using data scaffolding. The view has a textfield:</p>
  
  <p><strong>Create View:</strong></p>
  
  <pre><code>     &lt;div class="form-group"&gt;
          @Html.LabelFor(model =&gt; model.GroupId, htmlAttributes: new { @class = "control-label col-md-2" })
          &lt;div class="col-md-10"&gt;
              @Html.EditorFor(model =&gt; model.GroupId, new { htmlAttributes = new { @class = "form-control" } })
              @Html.ValidationMessageFor(model =&gt; model.GroupId, "", new { @class = "text-danger" })
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>I'd like to pass a value from a controller to this textfield. And I did the following, which doesn't seem to work. </p>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>    public ActionResult Create(int id)
      {
          ViewBag.GroupId = id;
          Debug.WriteLine("DEBUG: "+id);
          return View();
      }
  </code></pre>