title: Html.DropDownListFor selectedvalue not showing on postback
body: <p>In my view, there are 5 dropdownlists. The first one is populated when the user first gets to the page. Then the rest of the dropdowns are populated based on what they select from the dropdowns. The binding of the dropdowns work fine..no problem. Basically, there is a submit button on the page which displays the results from the values selected from the dropdowns. The problem is on HttpPost, whatever was selected from the dropdown, they disappear. The other thing is while i keep changing the selectedvalue and do submit, they show up. </p>
  
  <p>For example, i select values from each of the dropdowns. Do a submit, the results display and only the first one shows the selected value. The rest are gone. Then on the same time, I select the remaining values, do a submit, now the first and second show up and the rest are gone. I repeat the same thing, do a postback and the 1st, second and thrid show up and the remaining are gone. Not sure whats happening here. Let me know if I would need to update this post with my code. Just wanted to check if there is quick fix before i post what i did.</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          $('select#NationId').change(function () {
              var nationId = $(this).val();
              $.ajax({
                  url: 'LoadAreas',
                  type: 'POST',
                  data: JSON.stringify({ nationId: nationId }),
                  dataType: 'json',
                  contentType: 'application/json',
                  success: function (data) {
                      $('select#AreaId').get(0).options.length = 0;
                      $('select#AreaId').append('&lt;option value="0"&gt;Select All&lt;/option&gt;');
                      $.each(data, function (val, Areas) {
                          $('select#AreaId').append('&lt;option value="' + Areas.Id + '"&gt;' + Areas.Name + '&lt;/option&gt;');
                      });
                  }
              });
          });
          $('select#AreaId').change(function () {
              var areaId = $(this).val();
              $.ajax({
                  url: 'LoadDistricts',
                  type: 'POST',
                  data: JSON.stringify({ areaId: areaId }),
                  dataType: 'json',
                  contentType: 'application/json',
                  success: function (data) {
                      $('select#DistrictId').get(0).options.length = 0;
                      $('select#DistrictId').append('&lt;option value="0"&gt;Select All&lt;/option&gt;');
                      $.each(data, function (val, Districts) {
                          $('select#DistrictId').append('&lt;option value="' + Districts.Id + '"&gt;' + Districts.Name + '&lt;/option&gt;');
                      });
                  }
              });
          });
          $('select#DistrictId').change(function () {
              var districtId = $(this).val();
              $.ajax({
                  url: 'LoadTerritoryManagers',
                  type: 'POST',
                  data: JSON.stringify({ districtId: districtId }),
                  dataType: 'json',
                  contentType: 'application/json',
                  success: function (data) {
                      $('select#TMId').get(0).options.length = 0;
                      $('select#TMId').append('&lt;option value="0"&gt;Select All&lt;/option&gt;');
                      $.each(data, function (val, TMManagers) {
                          $('select#TMId').append('&lt;option value="' + TMManagers.Id + '"&gt;' + TMManagers.Name + '&lt;/option&gt;');
                      });
                  }
              });
          });
          $("#TMId").change(function () {
              var tmId = $(this).val();
              $.ajax({
                  url: 'LoadDealers',
                  type: 'POST',
                  data: JSON.stringify({ tmId: tmId }),
                  dataType: 'json',
                  contentType: 'application/json',
                  success: function (data) {
                      $("#ChannelId").get(0).options.length = 0;
                      $("#ChannelId").append('&lt;option value="0"&gt;Select All&lt;/option&gt;');
                      $.each(data, function (val, SurveyDealers) {
                          $("#ChannelId").append('&lt;option value="' + SurveyDealers.Id + '"&gt;' + SurveyDealers.DealerId + '&lt;/option&gt;');
                      });
                  }
              });
          });
      });
  &lt;/script&gt;
  @using (Html.BeginForm())
  {
      &lt;div style="width: 100%; font-size: 14px; font-family: Arial, Helvetica, sans-serif;"&gt;
          &lt;div align="right" style="padding-top: 10px;"&gt;
              @Html.ActionLink("Back to Reports page", "Index", "Reports/Customers", new { area = "" }, new { @class = "PremireButton" })
          &lt;/div&gt;
          &lt;h3  style="background-color: #CC0000; color: #fff; font-size: 1.5em;"&gt;
              Customer Survey Report&lt;/h3&gt;
          &lt;table width="50%" cellpadding="0" cellspacing="0" style="padding: 10px 0 5px 5px;"&gt;
              @if (Model.ShowNational)
              {
                  &lt;tr&gt;
                      &lt;td style="padding: 5px 0 5px 5px;"&gt;
                          &lt;b&gt;Select a Country:&lt;/b&gt;
                      &lt;/td&gt;
                      &lt;td style="padding: 5px 0 5px 5px;"&gt;@Html.DropDownListFor(m =&gt; m.NationId, Model.NationalChannelGroups, "Select All")
                      &lt;/td&gt;
                  &lt;/tr&gt;
              }
              @if (Model.ShowArea)
              {
                  &lt;tr&gt;
                      &lt;td style="padding: 5px 0 5px 5px;"&gt;
                          &lt;b&gt;Select an Area:&lt;/b&gt;
                      &lt;/td&gt;
                      &lt;td style="padding: 5px 0 5px 5px;"&gt;@Html.DropDownListFor(m =&gt; m.AreaId, Model.AreaChannelGroups, "Select All")
                      &lt;/td&gt;
                  &lt;/tr&gt;
              }
              @if (Model.ShowDistrict)
              {
                  &lt;tr&gt;
                      &lt;td style="padding: 5px 0 5px 5px;"&gt;
                          &lt;b&gt;Select a District:&lt;/b&gt;
                      &lt;/td&gt;
                      &lt;td style="padding: 5px 0 5px 5px;"&gt;@Html.DropDownListFor(m =&gt; m.DistrictId, Model.DistrictChannelGroups, "Select All")
                      &lt;/td&gt;
                  &lt;/tr&gt;
              }
              @if (Model.ShowTM)
              {
                  &lt;tr&gt;
                      &lt;td style="padding: 5px 0 5px 5px;"&gt;
                          &lt;b&gt;Select a TM:&lt;/b&gt;
                      &lt;/td&gt;
                      &lt;td style="padding: 5px 0 5px 5px;"&gt;@Html.DropDownListFor(m =&gt; m.TMId, Model.TMChannelGroups, "Select All")
                      &lt;/td&gt;
                  &lt;/tr&gt;
              }
              &lt;tr&gt;
                  &lt;td style="padding: 5px 0 5px 5px;"&gt;
                      &lt;b&gt;Select a Dealer:&lt;/b&gt;
                  &lt;/td&gt;
                  &lt;td style="padding: 5px 0 5px 5px;"&gt;@Html.DropDownListFor(m =&gt; m.ChannelId, Model.Channels, "Select All")
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td colspan="2"&gt;
                      &lt;input type="submit" value="Submit" id="Submit" class="PremierSubmitButton" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
          @if (Model.ShowCustomerReport)
          {
          if (Model.Report.Count() &gt; 0)
          {
              &lt;table id="SurveyResponse" width="100%" cellpadding="0" cellspacing="0" style="font-size: 11px;"&gt;
                  &lt;thead&gt;
                      &lt;tr class="header"&gt;
                          &lt;td style="padding: 2px 2px 2px 2px;"&gt;
                              Dealer #
                          &lt;/td&gt;
                          &lt;td style="padding: 2px 2px 2px 2px;"&gt;
                              District
                          &lt;/td&gt;
                          &lt;td style="padding: 2px 2px 2px 2px;"&gt;
                              TM
                          &lt;/td&gt;
                          &lt;td style="padding: 2px 2px 2px 2px;"&gt;
                              Survey Code
                          &lt;/td&gt;
                          &lt;td style="padding: 2px 2px 2px 2px;"&gt;
                              First Name
                          &lt;/td&gt;
                          &lt;td style="padding: 2px 2px 2px 2px;"&gt;
                              Last Name
                          &lt;/td&gt;
                          &lt;td style="padding: 2px 2px 2px 2px;"&gt;
                              Address
                          &lt;/td&gt;
                          &lt;td style="padding: 2px 2px 2px 2px;"&gt;
                              City
                          &lt;/td&gt;
                          &lt;td style="padding: 2px 2px 2px 2px;"&gt;
                              State
                          &lt;/td&gt;
                          &lt;td style="padding: 2px 2px 2px 2px;"&gt;
                              Postal Code
                          &lt;/td&gt;
                          &lt;td style="padding: 2px 2px 2px 2px;"&gt;
                              Phone
                          &lt;/td&gt;
                          &lt;td style="padding: 2px 2px 2px 2px;"&gt;
                              Mail Sent
                          &lt;/td&gt;
                          &lt;td style="padding: 2px 2px 2px 2px;"&gt;
                              Email Sent
                          &lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/thead&gt;
                  &lt;tbody&gt;
                      @{bool alternate = false;}
                      @foreach (var tr in Model.Report)
                      {
                          &lt;tr @(alternate ? "class=alternate" : "")&gt;
                              &lt;td style="padding: 2px 2px 2px 2px;"&gt;
                                  @tr.DealerId
                              &lt;/td&gt;
                              &lt;td style="padding: 2px 2px 2px 2px;"&gt;
                                  @tr.District
                              &lt;/td&gt;
                              &lt;td style="padding: 2px 2px 2px 2px;"&gt;@tr.TM
                              &lt;/td&gt;
                              &lt;td style="padding: 2px 2px 2px 2px;"&gt;@tr.SurveyCode
                              &lt;/td&gt;
                              &lt;td style="padding: 2px 2px 2px 2px;"&gt;@tr.FirstName
                              &lt;/td&gt;
                              &lt;td style="padding: 2px 2px 2px 2px;"&gt;@tr.LastName
                              &lt;/td&gt;
                              &lt;td style="padding: 2px 2px 2px 2px;"&gt;@tr.Address
                              &lt;/td&gt;
                              &lt;td style="padding: 2px 2px 2px 2px;"&gt;@tr.City
                              &lt;/td&gt;
                              &lt;td style="padding: 2px 2px 2px 2px;"&gt;@tr.State
                              &lt;/td&gt;
                              &lt;td style="padding: 2px 2px 2px 2px;"&gt;@tr.PostalCode
                              &lt;/td&gt;
                              &lt;td style="padding: 2px 2px 2px 2px;"&gt;@tr.Phone
                              &lt;/td&gt;
                              &lt;td style="padding: 2px 2px 2px 2px;"&gt;@(tr.MailSent.HasValue ? @tr.MailSent.Value.ToShortDateString() : String.Empty)
                              &lt;/td&gt;
                              &lt;td style="padding: 2px 2px 2px 2px;"&gt;@(tr.DateCompleted.HasValue ? @tr.DateCompleted.Value.ToShortDateString() : String.Empty)
                              &lt;/td&gt;
                          &lt;/tr&gt;
                             alternate = !alternate;
                      }
                  &lt;/tbody&gt;
              &lt;/table&gt;
          }
          else
          {
              &lt;text&gt;There are no records to display&lt;/text&gt;
          }
         }
      &lt;/div&gt;
  }
  </code></pre>
  
  <p>Here is my HttpPost</p>
  
  <pre><code>[HttpPost]
      public ActionResult CustomerReport(AreaManagerModel model)
      { 
           //Display Result here
           LoadDropDowns(model);
           return View("CustomerReport", model);
      }
  
  private void LoadDropDowns(AreaManagerModel model)
      {
          var user = db.Users.Find(SessionHandler.CurrentUser.UserId);
          model.TMChannelGroups = new List&lt;SelectListItem&gt;();
          model.Channels = new List&lt;SelectListItem&gt;();
          model.AreaChannelGroups = new List&lt;SelectListItem&gt;();
          model.NationalChannelGroups = new List&lt;SelectListItem&gt;();
          model.DistrictChannelGroups = new List&lt;SelectListItem&gt;();
  
          var _signedInChannelGroupId = from s in user.ChannelGroups
                                        select s;
          if (_signedInChannelGroupId.Count() &gt; 0)
              model.LoggedChannelGroupId = _signedInChannelGroupId.Select(m =&gt; m.ChannelGroupId).First();
  
          var org = (from o in user.ManagedOrganizations
                     //where o.OrganizationId == 4
                     where o.OrganizationId == 8
                     select o).FirstOrDefault();
          if (org != null || user.IsSuperUser)
          {
              model.ShowNational = true;
              model.ShowArea = true;
              model.ShowDistrict = true;
              model.ShowTM = true;
  
              model.NationalChannelGroups = from i in db.ChannelGroups
                                            //where i.ChannelGroupTypeId == 4
                                            where i.ChannelGroupTypeId == 6
                                            select new SelectListItem()
                                            {
                                                Text = i.Name,
                                                Value = SqlFunctions.StringConvert((double)i.ChannelGroupId)
                                            };
              if (model.NationId != 0)
              {
                  var ngroup = (from g in SessionHandler.CurrentContext.ChannelGroups
                                //where g.ChannelGroupTypeId == 4
                                where g.ChannelGroupTypeId == 6
                                select g).FirstOrDefault();
                  if (ngroup != null)
                  {
                      model.AreaChannelGroups = from i in ngroup.Children
                                                select new SelectListItem()
                                                {
                                                    Text = i.Name,
                                                    Value = i.ChannelGroupId.ToString()
                                                };
                  }
                  var agroup = (from g in SessionHandler.CurrentContext.ChannelGroups
                                where g.ChannelGroupTypeId == 1
                                select g).FirstOrDefault();
                  if (agroup != null)
                  {
                      model.DistrictChannelGroups = from i in agroup.Children
                                                    select new SelectListItem()
                                                    {
                                                        Text = i.Name,
                                                        Value = i.ChannelGroupId.ToString()
                                                    };
                  }
                  var dgroup = (from g in SessionHandler.CurrentContext.ChannelGroups
                                where g.ChannelGroupTypeId == 2
                                select g).FirstOrDefault();
                  if (dgroup != null)
                  {
                      model.TMChannelGroups = from i in dgroup.Children
                                              select new SelectListItem()
                                              {
                                                  Text = i.Name,
                                                  Value = i.ChannelGroupId.ToString()
                                              };
                  }
                  var tgroup = (from g in SessionHandler.CurrentContext.ChannelGroups
                                where g.ChannelGroupTypeId == 3
                                select g).FirstOrDefault();
                  if (tgroup != null)
                  {
                      model.Channels = from i in tgroup.GetAllChannels()
                                       select new SelectListItem()
                                       {
                                           Text = i.ExternalChannelId,
                                           Value = i.ChannelId.ToString()
                                       };
                  }
              }
          }
          else
          {
              var ngroup = (from g in user.ChannelGroups
                            //where g.ChannelGroupTypeId == 4
                            where g.ChannelGroupTypeId == 6
                            select g).FirstOrDefault();
              if (ngroup != null)
              {
                  model.ShowNational = false;
                  model.ShowArea = true;
                  model.ShowDistrict = true;
                  model.ShowTM = true;
  
                  model.AreaChannelGroups = from i in ngroup.Children
                                            select new SelectListItem()
                                            {
                                                Text = i.Name,
                                                Value = SqlFunctions.StringConvert((double)i.ChannelGroupId)
                                            };
                  if (model.AreaId != 0)
                  {
                      var agroup = (from g in SessionHandler.CurrentContext.ChannelGroups
                                    where g.ChannelGroupTypeId == 1
                                    select g).FirstOrDefault();
                      if (agroup != null)
                      {
                          model.DistrictChannelGroups = from i in agroup.Children
                                                        select new SelectListItem()
                                                        {
                                                            Text = i.Name,
                                                            Value = i.ChannelGroupId.ToString()
                                                        };
                      }
                      var dgroup = (from g in SessionHandler.CurrentContext.ChannelGroups
                                    where g.ChannelGroupTypeId == 2
                                    select g).FirstOrDefault();
                      if (dgroup != null)
                      {
                          model.TMChannelGroups = from i in dgroup.Children
                                                  select new SelectListItem()
                                                  {
                                                      Text = i.Name,
                                                      Value = i.ChannelGroupId.ToString()
                                                  };
                      }
                      var tgroup = (from g in SessionHandler.CurrentContext.ChannelGroups
                                    where g.ChannelGroupTypeId == 3
                                    select g).FirstOrDefault();
                      if (tgroup != null)
                      {
                          model.Channels = from i in tgroup.GetAllChannels()
                                           select new SelectListItem()
                                           {
                                               Text = i.ExternalChannelId,
                                               Value = i.ChannelId.ToString()
                                           };
                      }
                  }
              }
              else
              {
                  var agroup = (from g in user.ChannelGroups
                                where g.ChannelGroupTypeId == 1
                                select g).FirstOrDefault();
                  if (agroup != null)
                  {
                      model.ShowNational = false;
                      model.ShowArea = false;
                      model.ShowDistrict = true;
                      model.ShowTM = true;
                      model.DistrictChannelGroups = from i in agroup.Children
                                                    select new SelectListItem()
                                                    {
                                                        Text = i.Name,
                                                        Value = i.ChannelGroupId.ToString()
                                                    };
                      if (model.DistrictId != 0)
                      {
                          var dgroup = (from g in SessionHandler.CurrentContext.ChannelGroups
                                        where g.ChannelGroupTypeId == 2
                                        select g).FirstOrDefault();
                          if (dgroup != null)
                          {
                              model.TMChannelGroups = from i in dgroup.Children
                                                      select new SelectListItem()
                                                      {
                                                          Text = i.Name,
                                                          Value = i.ChannelGroupId.ToString()
                                                      };
                          }
                          var tgroup = (from g in SessionHandler.CurrentContext.ChannelGroups
                                        where g.ChannelGroupTypeId == 3
                                        select g).FirstOrDefault();
                          if (tgroup != null)
                          {
                              model.Channels = from i in tgroup.GetAllChannels()
                                               select new SelectListItem()
                                               {
                                                   Text = i.ExternalChannelId,
                                                   Value = i.ChannelId.ToString()
                                               };
                          }
                      }
                  }
                  else
                  {
                      var dgroup = (from g in user.ChannelGroups
                                    where g.ChannelGroupTypeId == 2
                                    select g).FirstOrDefault();
                      if (dgroup != null)
                      {
                          model.ShowNational = false;
                          model.ShowArea = false;
                          model.ShowDistrict = false;
                          model.ShowTM = true;
                          model.TMChannelGroups = from i in dgroup.Children
                                                  select new SelectListItem()
                                                  {
                                                      Text = i.Name,
                                                      Value = i.ChannelGroupId.ToString()
                                                  };
                          if (model.TMId != 0)
                          {
                              var tgroup = (from g in SessionHandler.CurrentContext.ChannelGroups
                                              where g.ChannelGroupTypeId == 3
                                              select g).FirstOrDefault();
                          if (tgroup != null)
                          {
                              model.Channels = from i in tgroup.GetAllChannels()
                                               select new SelectListItem()
                                               {
                                                   Text = i.ExternalChannelId,
                                                   Value = i.ChannelId.ToString()
                                               };
                          }
                          }
                      }
                      else
                      {
                          var tgroup = (from g in user.ChannelGroups
                                        where g.ChannelGroupTypeId == 3
                                        select g).FirstOrDefault();
                          if (tgroup != null)
                          {
                              model.ShowNational = false;
                              model.ShowArea = false;
                              model.ShowDistrict = false;
                              model.ShowTM = false;
                              model.Channels = from i in tgroup.GetAllChannels()
                                               select new SelectListItem()
                                               {
                                                   Text = i.ExternalChannelId,
                                                   Value = i.ChannelId.ToString()
                                               };
                          }
                      }
                  }
              }
          }
      }
  </code></pre>
  
  <p>UPDATE:</p>
  
  <pre><code>[HttpPost]
      public ActionResult LoadAreas(int nationId)
      {
          var _Areas = (from c in SessionHandler.CurrentContext.ChannelGroups
                        join cgt in SessionHandler.CurrentContext.ChannelGroupTypes on c.ChannelGroupTypeId equals cgt.ChannelGroupTypeId
                        where cgt.Name == "Area" &amp;&amp; c.ParentChannelGroupId == nationId
                        select new AreaName() { Id = c.ChannelGroupId, Name = c.Name }).OrderBy(m =&gt; m.Name);
  
          if (_Areas == null)
              return Json(null);
          List&lt;AreaName&gt; managers = (List&lt;AreaName&gt;)_Areas.ToList();
  
          return Json(managers);
      }
      [HttpPost]
      public ActionResult LoadDistricts(int areaId)
      {
          var _Districts = (from c in SessionHandler.CurrentContext.ChannelGroups
                      join cgt in SessionHandler.CurrentContext.ChannelGroupTypes on c.ChannelGroupTypeId equals cgt.ChannelGroupTypeId
                      where cgt.Name == "District" &amp;&amp; c.ParentChannelGroupId == areaId
                      select new DistrictName() { Id = c.ChannelGroupId, Name = c.Name }).OrderBy(m =&gt; m.Name);
  
          if (_Districts == null)
              return Json(null);
  
          List&lt;DistrictName&gt; managers = (List&lt;DistrictName&gt;)_Districts.ToList();
          return Json(managers);
      }
      [HttpPost]
      public ActionResult LoadTerritoryManagers(int districtId)
      {
          var _TMS = (from c in SessionHandler.CurrentContext.ChannelGroups
                      join cgt in SessionHandler.CurrentContext.ChannelGroupTypes on c.ChannelGroupTypeId equals cgt.ChannelGroupTypeId
                      where cgt.Name == "Territory" &amp;&amp; c.ParentChannelGroupId == districtId
                      select new TMManager() { Id = c.ChannelGroupId, Name = c.Name }).OrderBy(m =&gt; m.Name);
  
          if (_TMS == null)
              return Json(null);
  
          List&lt;TMManager&gt; managers = (List&lt;TMManager&gt;)_TMS.ToList();
          return Json(managers);
      }
      [HttpPost]
      public ActionResult LoadDealers(int tmId)
      {
          var _dealers = (from c in SessionHandler.CurrentContext.Channels
                      where c.ChannelGroupId == tmId
                      select new SurveyDealer() { Id = c.ChannelId, DealerId = c.ExternalChannelId }).OrderBy(m =&gt; m.DealerId);
  
          if (_dealers == null)
              return Json(null);
  
          List&lt;SurveyDealer&gt; dealers = (List&lt;SurveyDealer&gt;)_dealers.ToList();
          return Json(dealers);
      }
  </code></pre>