title: Displaying attribute of ViewBag depending on the selected item from DropDownList
body: <p>I want to display the price of the selected item in the textbox in the view. For example, a product selected from the DLL has a price of 10 € and it should be displayed in the view. Can someone help?</p>
  
  <p>Controler</p>
  
  <pre><code>    public ActionResult Edit(int id)
      {
          Product product = DB.Products.Find(id);
          ViewBag.Formats = new SelectList(storeDB.Format, "FormatID", "FormatName", "Price");
          ViewBag.Foo = "Some Value";     //test
          return View(product);
      }
  </code></pre>
  
  <p>View</p>
  
  <pre><code>@using (Html.BeginForm())
  {
      @Html.ValidationSummary(true)
      &lt;fieldset&gt;
  
          &lt;div class="editor-field"&gt;
              @Html.DropDownList("Formats", ViewBag.Formats as SelectList, new { id = "DDLFormatsID" })
              @Html.Display("Price")        //displays nothing
              @Html.Display("Foo")          //working properly
          &lt;/div&gt;
  
      &lt;/fieldset&gt;
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/E6SuH.png" alt="This can explain more."></p>
  
  <p>Update:</p>
  
  <p><img src="https://i.stack.imgur.com/mTb55.jpg" alt="update"></p>