title: Fill textbox on dropdown selection in mvc entity framework
body: <p>I am using Asp.net MVC5 and Entity Framework.I am new in Both of technologies.</p>
  
  <p>Basically i create a Form, In this Form a DropDown available, when i select value from DropDown. I want to fill Textboxs which also available on this form.</p>
  
  <p><strong>This is my Controller</strong></p>
  
  <pre><code>public class ChainController : Controller
  {
      private hcEntities db = new hcEntities();
  
      // GET: Chain
      public ActionResult Index()
      {
          ViewBag.name = new SelectList(db.chains,"code","name");
          return View(db.chains.ToList());
      }
  }
  </code></pre>
  
  <p><strong>View:-</strong></p>
  
  <pre><code>&lt;div class="form-horizontal"&gt;
      &lt;hr /&gt;
      &lt;div class="form-group"&gt;
          &lt;label class="col-sm-2 control-label"&gt;
              Select Chain
          &lt;/label&gt;
          &lt;div class="col-md-3"&gt;            
              @Html.DropDownList("name" , null, new { @class = "form-control" })           
          &lt;/div&gt;
      &lt;/div&gt;
   @using (@Html.BeginForm())
   {
      @Html.AntiForgeryToken()
      &lt;div class="form-group"&gt;
          &lt;label class="col-sm-2 control-label"&gt;
              Chain UserName
          &lt;/label&gt;
          &lt;div class="col-md-3"&gt;            
             @Html.TextBox("ChainName", null, new { @class = "form-control" }) //WHAT DO I DO HERE???????
          &lt;/div&gt;
      &lt;/div&gt;
   }
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Model(chain.cs generated by EF)</strong></p>
  
  <pre><code>public partial class chain
  {
      public long chain_id { get; set; }
      public string name { get; set; }
      public string code { get; set; }
      public string username { get; set; }
      public string password { get; set; }
      public long created_by { get; set; }
      public System.DateTime created_on { get; set; }
      public Nullable&lt;long&gt; updated_by { get; set; }
      public Nullable&lt;System.DateTime&gt; updated_on { get; set; }
      public chain()
      {
          created_by = 1;
          created_on = DateTime.Now;
      }
  }
  </code></pre>
  
  <p>I don't know what will be next step. how to fill textbox with value of <strong>Username</strong> from the selection of dropdown.
  I find too many answer in stackoverflow but i fill these are not helpful for me. for example
  <a href="https://stackoverflow.com/questions/22563819/fill-the-textboxes-with-selecting-dropdownlist-in-mvc">fill the textboxes with selecting dropdownlist in mvc</a>, <a href="https://stackoverflow.com/questions/16814450/how-to-populate-a-textbox-based-on-dropdown-selection-in-mvc">How to populate a textbox based on dropdown selection in MVC..?</a></p>
  
  <p>Help Me !</p>