title: How to fix a System.FormatException when dropdownlist is set to default?
body: <p>I am having "An exception of type 'System.FormatException' occurred in mscorlib.dll but was not handled in user code." Additional information: Input string was not in a correct format. I have a dropdown list, #Carriers, when user selects an item no errors occur, however, when user selects the dropdownlist back to default it show this error. I need a way to write an if statement to check for null values. </p>
  
  <pre><code> [AcceptVerbs(HttpVerbs.Get)]
      public JsonResult LoadAccsByCarrierId(string carrierid)
      {
  
              var accsList = this.GetAccs(Convert.ToInt32(carrierid));
              var accsData = accsList.Select(m =&gt; new SelectListItem()
              {
                  Text = m.AccessoryName,
                  Value = m.AccessoryID.ToString(),
              });
              return Json(accsData, JsonRequestBehavior.AllowGet);
      }
  
       [AcceptVerbs(HttpVerbs.Get)]
      public JsonResult LoadPhonesByCarrierId(string carrierid, string emailaddress)
      {
          int id;
          var phonesData = new List&lt;SelectListItem&gt;();
          if (Int32.TryParse(carrierid, out id))
          {
              var phonesList = this.GetPhones(id, emailaddress);
              phonesData = phonesList.Select(m =&gt; new SelectListItem()
              {
                  Text = m.Name,
                  Value = m.PhoneID.ToString(),
              }).ToList();
              return Json(phonesData, JsonRequestBehavior.AllowGet);
          }
          else
              return null; 
      }
  </code></pre>