title: how to bind data to label in asp.net mvc3
body: <p>I have three model  Classes(code first)</p>
  
  <p>ProductGroup(p)->product(c)(list of produGroups comes in  drop down list while creating a new product),</p>
  
  <p>Now my requirement is,</p>
  
  <p>Product(p)->PreferedLocation(c),
  when I select preferedLocation(Create action) link ,I have to fill the details for the particular product.Means first I need to display single product name in Label like Product:Mango</p>
  
  <p>In controller</p>
  
  <pre><code>    public ActionResult  PreferedLocation()
      {
          ViewBag.ProductID = new  SelectList(db.Products,"ProductID","Name");
         //ViewBag.CountryID = new SelectList(db.Countries, "CountryID", "Name");
          return View();
  
      }
  
      //
      // POST: /PreferedLocation/Create
  
      [HttpPost]
      public ActionResult PreferedLocation(PreferredLocation preferredlocation)
      {
          if (ModelState.IsValid)
          {
              db.PreferredLocations.Add(preferredlocation);
              db.SaveChanges();
              return RedirectToAction("Index");
          }
          // ViewBag.ProductID = new SelectList(db.Products, "ProductID", "Name", preferredlocation.ProductID);
  
          return View(preferredlocation);
      }
  </code></pre>
  
  <p>In View:</p>
  
  <pre><code>    &lt;div class="editor-field"&gt;
          &lt;%: Html.EditorFor(model =&gt; model.Name) %&gt;
  
          &lt;%: Html.ValidationMessageFor(model =&gt; model.Name) %&gt;
      &lt;/div&gt;
  
      &lt;div class="editor-label"&gt;
          &lt;%: Html.LabelFor(model =&gt; model.StreetAdress) %&gt;
      &lt;/div&gt;
      &lt;div class="editor-field"&gt;
          &lt;%: Html.EditorFor(model =&gt; model.StreetAdress) %&gt;
          &lt;%: Html.ValidationMessageFor(model =&gt; model.StreetAdress) %&gt;
      &lt;/div&gt;
  
      &lt;div class="editor-label"&gt;
          &lt;%: Html.LabelFor(model =&gt; model.Description) %&gt;
      &lt;/div&gt;
      &lt;div class="editor-field"&gt;
          &lt;%: Html.EditorFor(model =&gt; model.Description) %&gt;
          &lt;%: Html.ValidationMessageFor(model =&gt; model.Description) %&gt;
      &lt;/div&gt;
  
      &lt;div class="editor-label"&gt;
          &lt;%: Html.LabelFor(model =&gt; model.Latitude) %&gt;
      &lt;/div&gt;
      &lt;div class="editor-field"&gt;
          &lt;%: Html.EditorFor(model =&gt; model.Latitude) %&gt;
          &lt;%: Html.ValidationMessageFor(model =&gt; model.Latitude) %&gt;
      &lt;/div&gt;
  
              &lt;div class="display-label"&gt;product&lt;/div&gt;
  &lt;div class="display-field"&gt;
      &lt;%: Html.LabelFor(model=&gt;Model.Product.Name) %&gt;
      &lt;%: Html.ValidationMessageFor(model =&gt; model.ProductID) %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here I tried Code for idsplaying product name in label
  but instead of product name I got output as</p>
  
  <p>product</p>
  
  <p>Product Name.</p>
  
  <p>What modifications I have to do.</p>