title: Getting the Value from a Datatype Dropdown (Umbraco)
body: <p>I am trying to get the name or shall i say the value of the dropdown pre value created using the umbraco datatype "dropdown"</p>
  
  <p><a href="https://i.stack.imgur.com/mAP6F.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mAP6F.png" alt="Service Dropdown List Values"></a></p>
  
  <p>Now when specifying the "id" it gets the number, how do i get the value of that "id"?</p>
  
  <p>Here is the dropdown populated with the id of the values;</p>
  
  <p><a href="https://i.stack.imgur.com/nrE0k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nrE0k.png" alt="Populated Dropdown with IDs"></a></p>
  
  <p>How do i get the value name? And not the ID?</p>
  
  <p>Here is the Surface Controller;</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using System.Xml.XPath;
  using Umbraco.Core.Services;
  using Umbraco.Web.Mvc;
  
  /// &lt;summary&gt;
  /// Summary description for ContactSurfaceController
  /// &lt;/summary&gt;
  
  namespace LiquidThinker2015
  {
      public class ContactSurfaceController : SurfaceController
      {
          public object XPathModeIterator { get; private set; }
  
          public ActionResult ShowForm()
          {
              ContactModel myModel = new ContactModel();
              List&lt;SelectListItem&gt; ListOfServices = new List&lt;SelectListItem&gt;();
              XPathNodeIterator iterator = umbraco.library.GetPreValues(1435);
              iterator.MoveNext();
              XPathNodeIterator preValues = iterator.Current.SelectChildren("preValue", "");
              while (preValues.MoveNext())
              {
                  string preValue = preValues.Current.GetAttribute("id","");
                  ListOfServices.Add(new SelectListItem
                  {
                      Text = preValue,
                      Value = preValue
                  });
                  myModel.ListOfServices = ListOfServices;
              }
              return PartialView("ContactForm", myModel);
          }
  
          public ActionResult HandleFormPost(ContactModel model)
          {
              var newComment = Services.ContentService.CreateContent(model.Name + " - " + DateTime.Now.ToString("dd/MM/yyyy HH:mm"), CurrentPage.Id, "ContactFormula");
  
              //DataTypeService myService = new DataTypeService();
              //var SelectedService = myService.GetAllDataTypeDefinitions().First(x =&gt; x.Id == 1435);
              //int SelectedServicePreValueId = myService.GetPreValuesCollectionByDataTypeId(SelectedService.Id).PreValuesAsDictionary.Where(x =&gt; x.Value.Value == model.SelectedService).Select(x =&gt; x.Value.Id).First();
  
  
              newComment.SetValue("contactName", model.Name);
              newComment.SetValue("companyName", model.Company);
              newComment.SetValue("emailFrom", model.Email);
              newComment.SetValue("telephoneNumber", model.Telephone);
              newComment.SetValue("dropdownServices", model.SelectedService);
              newComment.SetValue("contactMessage", model.Message);
  
              Services.ContentService.SaveAndPublishWithStatus(newComment);
  
              return RedirectToCurrentUmbracoPage();
          }
      }
  }
  </code></pre>
  
  <p>Thanks</p>