title: How can I link a DropDown and Textbox to my Model's data?
body: <p>Here is the code for my Model. ListBuilder.DropDown is part of a common class of functions, which simply returns a List when provided the string name of a stored procedure that will be called on the database.</p>
  
  <p>There is some more shared common class code (stored procedure related) with in the try statement, but that implementation is irrelevant to the problem I'm having. The data is successfully retrieved and stored into the model.</p>
  
  <pre><code>public class PositionViewModel
  {
      [Display(Name = "Series")]
      public string series { get; set; }
      public int seriesID { get; set; }
      public List&lt;SelectListItem&gt; list_Series { get; set; }
  }
  
  public PositionViewModel(string id)
  {
      Get(id);
      this.list_Series = ListBuilder.DropDown(AppConstants.StoredProc_GetSeries);
  }
  
  
  public Position Get(string id)
  {
      ExecStoredProcedure sp = null;
      DataTable dt = new DataTable();
  
      try
      {
          sp = new ExecStoredProcedure(AppConstants.SP_POSITION_GET, new ConnectionManager().GetConnection(), AppConstants.SP_POSITION_GET);
          sp.SPAddParm("@PD_ID", SqlDbType.Char, id, ParameterDirection.Input);
  
          dt = sp.SPselect();
  
          if (dt.Rows.Count &gt; 0)
          {
              this.pd_id = dt.Rows[0]["PD_ID"].ToString();
              this.official_title = dt.Rows[0]["label"].ToString();
              this.series = dt.Rows[0]["Series"].ToString();
              this.grade = dt.Rows[0]["Grade"].ToString(); 
              this.PDType = dt.Rows[0]["PDType"].ToString();
          }
      }
  
      catch (Exception ex)
      {
          throw ex;
      }
  
      finally
      {
          sp.dbConnection.Close();
      }
  
      return this;
  
  }
  </code></pre>
  
  <p>Here is the code for my Controller</p>
  
  <pre><code>[HttpGet]
  public ActionResult PositionEdit(string id)
  {
      PositionViewModel model = new PositionViewModel(id);
      return View("PositionEdit", model);
  }
  
  [HttpPost]  
  public ActionResult PositionEdit(PositionViewModel model)
  {
      if (ModelState.IsValid)
      {
          int rc = model.Update();
          return RedirectToAction("PositionView");
      }
      else
      {
          return View("PositionEdit", model);
      }
  }
  </code></pre>
  
  <p>Here is the code for my view. What I'd like to have is a dropdownlist that contains the model.seriesID (a sequence number) but as the user selects an item, it will update the textbox with model.series (the name of the series)</p>
  
  <pre><code>@model Project.Models.PositionViewModel
  
  
  @{
      ViewBag.Title = "Edit Position Description";
  }
  
  @using (Html.BeginForm())
  {
      @Html.AntiForgeryToken()
      @Html.ValidationSummary(true)
  
  
  
      &lt;div class="editor-label"&gt;
          @Html.LabelFor(model =&gt; model.series)
      &lt;/div&gt;
  
  
      &lt;div class="editor-field"&gt;
          @Html.DropDownListFor(model =&gt; Model.seriesID, Model.list_Series, new { style = "width:550px" })
          @Html.ValidationMessageFor(model =&gt; Model.seriesID)
      &lt;/div&gt;
  
  
      &lt;div class="editor-field"&gt;
          @Html.TextBoxFor(model =&gt; model.series, new { style = "width:250px;" })
          @Html.ValidationMessageFor(model =&gt; model.series)
      &lt;/div&gt;
  
  
  
      &lt;div class="toppad20"&gt;
          &lt;input type="submit" value="Save" /&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>}</p>
  
  <p>I am having trouble linking the dropdownlist with the textbox. Do I need some kind of onChange event? Thanks in advance for your help.</p>