title: JSON to C# object using Data Contracts - What am I missing here?
body: <p>I am experiencing an error converting JSON to a strongly-typed class.</p>
  
  <p>My JSON: <code>{"listBoxID":"ctl00_ctl00_MainContentRoot_MainContent_lstBxSettings","sourceItemText":"Horizontal Bar","sourceItemValue":"Horizontal"}</code></p>
  
  <pre><code>DroppedItem droppedItem = JsonConvert.DeserializeObject&lt;DroppedItem&gt;(json);
  
  /// &lt;summary&gt;
  /// Outlines an object which is useful in simplifying how a CormantRadDock is created.
  /// Instead of passing in lots of parameters, would rather just pass in an object that the
  /// CormantRadDock knows how to interpret.
  /// &lt;/summary&gt;
  [DataContract]
  public class DroppedItem
  {
      private static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  
      [DataMember(Name = "sourceItemText")]
      public string Text { get; set; }
  
      [DataMember(Name = "sourceItemValue")]
      public string Value { get; set; }
  
      [DataMember(Name = "listBoxID")]
      public Reports ReportType { get; set; }
  
      public DroppedItem() { }
  
      public DroppedItem(string text, string value, string listBoxID)
      {
          Logger.DebugFormat("Text: {0}, Value: {1}, slidingPaneTitle: {2}", text, value, listBoxID);
          Text = text;
          Value = value;
          ReportType = DetermineReportType(listBoxID);
      }
  
      private Reports DetermineReportType(string listBoxID)
      {
          if (listBoxID.Contains("lstBxHistorical"))
          {
              return Reports.HistoricalReport;
          }
          else if (listBoxID.Contains("lstBxCustom"))
          {
              return Reports.CustomReport;
          }
          else
          {
              return Reports.None;
          }
      }
  }
  </code></pre>
  
  <p>The issue is with converting listBoxID to ReportType. </p>
  
  <blockquote>
    <p>Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: Error converting value "ctl00_ctl00_MainContentRoot_MainContent_lstBxSettings" to type 'CableSolve.Web.Reports'</p>
  </blockquote>
  
  <p>It occurs regardless of whether the if statement finds a hit or defaults to the else block. It does not occur if I do not attempt to pass the listBoxID parameter. </p>
  
  <p>I'm missing something here. Are my DataMember names not doing anything? I thought they would map the listBoxID to the correct property.</p>