title: How to show entered order no and selected product name and id
body: <p>i am new in mvc. so could not figure out what to add in code to show entered order no and selected product name and id.</p>
  
  <p>here is full code and <code>dotnetfiddle url https://dotnetfiddle.net/6vn2GO</code></p>
  
  <h2>Model code</h2>
  
  <pre><code>using System;
  using System.ComponentModel.DataAnnotations;
  using System.Web.Mvc;
  using System.Collections.Generic;
  
  namespace HelloWorldMvcApp
  {
      public class OrderViewModel
      {
          [Display(Name = "Order number")]
          public int? OrderNumber { set; get; }
          [Display(Name = "Product")]
          [Required(ErrorMessage = "Please select a product")]
          public int SelectedProductId { set; get;}
          public SelectList ProductList { get; set; }
      }
  
      public class Product
      {
          public int ID { set; get; }
          public string Name { set; get; }
      }
  
      public static class Repository
      {
          public static IEnumerable&lt;Product&gt; FetchProducts()
          {
              return new List&lt;Product&gt;()
              {
                  new Product(){ ID = 1, Name = "Ketchup" },
                  new Product(){ ID = 2, Name = "Mustard" },
                  new Product(){ ID = 3, Name = "Relish" }
              };
          }
      }
  
  }
  </code></pre>
  
  <h2>Controller code</h2>
  
  <pre><code>using System;
  using System.Web.Mvc;
  using System.Collections.Generic;
  
  namespace HelloWorldMvcApp
  {
      public class HomeController : Controller
      {
          [HttpGet]
          public ActionResult Index()
          {
              OrderViewModel model = new OrderViewModel();
              model.OrderNumber=null;
              ConfigureViewModel(model);
              return View(model);
          }
          [HttpPost]
          public ActionResult Index(OrderViewModel model)
          {
              if (!ModelState.IsValid)
              {
                  ConfigureViewModel(model);
                  return View(model);
              }
              // save and redirect
              // but for testing purposes
              ConfigureViewModel(model);
              return View(model);
          }
  
          private void ConfigureViewModel(OrderViewModel model)
          {
              IEnumerable&lt;Product&gt; products = Repository.FetchProducts();
              model.ProductList = new SelectList(products, "ID", "Name");
          }
      }
  }
  </code></pre>
  
  <h2>View.cshtml code</h2>
  
  <pre><code>@model HelloWorldMvcApp.OrderViewModel
  @{
      Layout = null;
  }
  
  &lt;!DOCTYPE html&gt;
  &lt;!-- template from http://getbootstrap.com/getting-started --&gt;
  
  &lt;html lang="en"&gt;
      &lt;head&gt;
          &lt;meta charset="utf-8"&gt;
          &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
          &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
          &lt;title&gt;Bootstrap 101 Template&lt;/title&gt;
  
          &lt;!-- CSS Includes --&gt;
          &lt;link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"&gt;
  
          &lt;style type="text/css"&gt;
  
              .field-validation-error {
                  color: #ff0000;
              }
  
          &lt;/style&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
          &lt;div class="container"&gt;
              &lt;div class="col-md-6 col-md-offset-3"&gt;
                  &lt;h1&gt;Hello Stranger&lt;/h1&gt;
                  @using (Html.BeginForm())
                  {
                      &lt;div class="form-group"&gt;
                          @Html.LabelFor(m =&gt; m.OrderNumber)
                          @Html.TextBoxFor(m =&gt; m.OrderNumber, new {@class="form-control"}) 
                          @Html.ValidationMessageFor(m =&gt; m.OrderNumber)
                      &lt;/div&gt;
                      &lt;div class="form-group"&gt;
                          @Html.LabelFor(m =&gt; m.SelectedProductId)
                          @Html.DropDownListFor(m =&gt; m.SelectedProductId, Model.ProductList, "-Please select-", new {@class="form-control"}) 
                          @Html.ValidationMessageFor(m =&gt; m.SelectedProductId)
                      &lt;/div&gt;
  
                      &lt;button type="submit" class="btn btn-success submit"&gt;Save&lt;/button&gt;
                  }
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;!-- JS includes --&gt;
          &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"&gt;&lt;/script&gt;
          &lt;script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"&gt;&lt;/script&gt;
  
          &lt;script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"&gt;&lt;/script&gt;
          &lt;script src="//ajax.aspnetcdn.com/ajax/mvc/4.0/jquery.validate.unobtrusive.min.js"&gt;&lt;/script&gt;
  
          &lt;script type="text/javascript"&gt;
  
          &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>please tell me what code i need to add in view html to show entered order no and selected product name and id. thanks</p>