title: Set Text Box value using drop-down list's selected value
body: <p>I have a schema ( table saved in Sql) like this:</p>
  
  <pre><code> ID | Name | Address
   1     Sam     ADD1
   2     John    ADD2
   3     Tony    ADD3
  </code></pre>
  
  <p>I have three fields in my form - <code>ID , Name and Address</code>. <br>
  Now  I have implemented a drop-down for the ID field using <code>ViewBag</code> to pass data between the view and the controller.<br>
   I want to set the value of the fields <code>Name and Address</code> using the ID selected from the drop-down and not manually but I am unable to figure out a way and tried searching but could not find any appropriate solution.<br>
  Thanks for the Help.</p>
  
  <p>EDIT: <br>
  My Code So Far: <br>
  Model Has been generated using the table itself (Database First Approach)<br>
  <strong>Controller</strong><br></p>
  
  <pre><code>        public ActionResult Create()
          {
              ViewBag.codes = db.Users.ToList();
  
              return View();
          }
  
  
          [HttpPost]
          [ValidateAntiForgeryToken]
          public ActionResult Create(Entity_Master entity_Master)
          {
              if (ModelState.IsValid)
              {
                  db.Entity_Master.Add(entity_Master);
                  db.SaveChanges();
                  return RedirectToAction("Index");
              }
              ViewBag.codes = db.Users.ToList();
              return View(entity_Master);
          }
  </code></pre>
  
  <p><br>
  <strong>View</strong><br></p>
  
  <pre><code>   @Html.LabelFor(model =&gt; model.ID, htmlAttributes: new { @class = "control-label col-md-2" })
  
        @Html.DropDownListFor(model =&gt; model.ID, new SelectList(ViewBag.codes, "ID", "ID", "Select ID"))
        @Html.ValidationMessageFor(model =&gt; model.ID, "", new { @class = "text-danger" })
  
  
     @Html.LabelFor(model =&gt; model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
  
        @Html.EditorFor(model =&gt; model.Name, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessageFor(model =&gt; model.Name, "", new { @class = "text-danger" })
  
  
     @Html.LabelFor(model =&gt; model.Address, htmlAttributes: new { @class = "control-label col-md-2" })
  
        @Html.EditorFor(model =&gt; model.Address, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessageFor(model =&gt; model.Address, "", new { @class = "text-danger" })
  </code></pre>
  
  <p><strong>Rendered Html</strong> <br></p>
  
  <pre><code>        &lt;select id="ID" name="ID"&gt;
          &lt;option value="1"&gt;1&lt;/option&gt;
          &lt;option value="2"&gt;2&lt;/option&gt;
          &lt;option value="3"&gt;3&lt;/option&gt;
          &lt;option value="4"&gt;4&lt;/option&gt;
          &lt;option value="5"&gt;5&lt;/option&gt;
          &lt;/select&gt;
        &lt;input class="form-control text-box single-line" id="Name" name="Name" type="text" value="" /&gt;
        &lt;span class="field-validation-valid text-danger" data-valmsg-for="Name" data-valmsg-replace="true"&gt;&lt;/span&gt;
        &lt;input class="form-control text-box single-line" id="Address" name="Address" type="text" value="" /&gt;
        &lt;span class="field-validation-valid text-danger" data-valmsg-for="Address" data-valmsg-replace="true"&gt;&lt;/span&gt;
  </code></pre>