title: Dispay data from database to textbox asp.net mvc
body: <p>How will I properly display data from database to textbox when the button "search" is clicked? It should display the item name and the price of that product code</p>
  
  <p><a href="http://i.stack.imgur.com/StKht.png" rel="nofollow">enter image description here</a></p>
  
  <p>Controller</p>
  
  <pre><code>public ActionResult Index(string searchString)
  {
      using(MyDatabaseEntities db = new MyDatabaseEntities())
      {
          var products = from s in db.Products
                         select s;
          if (!String.IsNullOrEmpty(searchString))
          {
              products = products.Where(s =&gt; s.ProductCode.Equals(searchString));
          }
          return View(products.ToList());
      }
  }
  </code></pre>
  
  <p>Index</p>
  
  <pre><code>&lt;div class="form-group"&gt;
      &lt;table style="text-align:left; margin-bottom:10px;"&gt;
          &lt;tr&gt;
              &lt;td&gt;Item Code&lt;/td&gt;
              &lt;td&gt;@Html.TextBox("SearchString")
          &lt;/td&gt;
          &lt;tr style="background-color:lightgray;"&gt;
              &lt;td colspan="2"&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td colspan="2"&gt;
                  &lt;input type="submit" class="btn btn-block btn-info"id="buttonsearch" value="Search" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;/tr&gt;  
          @foreach (var item in Model) { 
              &lt;tr&gt;
                  &lt;td style="text-align:left;"&gt;Item Name&lt;/td
                  &lt;td&gt;@Html.DisplayFor(modelItem=&gt; item.ProductName)&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Unit Price&lt;/td&gt;
                  &lt;td style="text-align:right;"&gt;@Html.DisplayFor(modelItem =&gt; item.Price)&lt;/td&gt;
              &lt;/tr&gt;
          }
          &lt;tr&gt;
              &lt;td style="text-align:left;"&gt;Quantity&lt;/td&gt;
              &lt;td&gt;
                  &lt;input type="text" id="quantity" class="input-sm" /&gt;
                  &lt;span class="error"&gt;Product Name  required&lt;/span&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style="text-align:left;"&gt;Discount&lt;/td&gt;
              &lt;td&gt;
                  &lt;input type="text" id="discount" class="input-sm" style="text-align:right;" placeholder="0.00" /&gt;
                  &lt;span class="error"&gt;Product Name required&lt;/span&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>