title: Input string was not in the correct format C# ASP.NET
body: <p>I am new to programming and currently working on a C# asp.net website that populates Telerik RadComboBoxes from a database on_load.</p>
  
  <p>I have a form that has 15+ ComboBoxes and when I select values from those ComboBoxes those ComboBox selections must be used to search through a really large table in my database. A gridView will display the returned data.</p>
  
  <p>I have used the same format of code throughout the rest of my project and it works perfectly, But when I select an item from my "Location" DropDownBox to search through my database I get the error <code>'Input string was not in a correct format'</code> and I cant figure out why</p>
  
  <p>here is my Location.cs Class</p>
  
  <h1>region Properties</h1>
  
  <pre><code>    [Key]
      public int LocationID { get; se; }
      [Column("Location")]
      public string LocationName { get; set; }
      private int? _ParentLocationID;
      [Column]
      public int? ParentLocationID
      {
          get
          {
              return _ParentLocationID;
          }
          set
          {
              if (value == 0)
              {
                  _ParentLocationID = null;
              }
              else
              {
                  _ParentLocationID = value;
              }
          }
      }
  
      [Column]
      public int SiteID { get; set; }
      [Column]
      public bool Active { get; set; }
  </code></pre>
  
  <h1>region Method</h1>
  
  <pre><code>    public static IEnumerable&lt;Location&gt; LoadActiveLocations(int siteID)
      {
          iThNkContext db = new iThNkContext();
  
          var LocationList = (from l in db.Locations
                                  where(l.SiteID == siteID &amp;&amp; l.Active == true)
                                  orderby l.LocationID
                                  select l).ToList();
  
          return LocationList;
      }
  </code></pre>
  
  <p>And here is the code I am using in my .aspx file</p>
  
  <pre><code>RadTreeView trvLocation = (RadTreeView)cboLocation.Controls[2].FindControl("trvLocation");
           if (trvLocation.SelectedValue != "")
           {
              var locationID = Convert.ToInt32(trvLocation.SelectedValue);  //Error
              predicates.Add(p =&gt; p.LocationID == locationID);
          }
  </code></pre>
  
  <p>On the //Error line is where I am getting the 'Input string was not in the correct format' error, any suggestions please. I cant understand why I am having this problem</p>
  
  <p>thank you in advance</p>