title: Unable to cast object of type '<>f__AnonymousType0`2[System.String,System.Int32]' to type 'System.IConvertible'
body: <p>I am trying to populate a data list box to text box on list box's click event but I found this error</p>
  
  <blockquote>
    <p>Additional information: Unable to cast object of type '&lt;>f__AnonymousType0`2[System.String,System.Int32]' to type 'System.IConvertible'</p>
  </blockquote>
  
  <pre><code>private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
  {
      StudenRecordDataContext std = new StudentRecordDataContext();
      int selectedValue = Convert.ToInt32(listBox1.SelectedValue);
      StudentRecord sr = std.StudentRecords.Single(s =&gt;s.ID==selectedValue);
      txtId.Text = sr.ID.ToString();
      txtName.Text = sr.Name;
      txtPassword.Text = sr.Password;
      txtCnic.Text = sr.CNIC;
      txtEmail.Text = sr.Email;
  }
  </code></pre>
  
  <p>I think the error is on line <code>StudentRecord sr = std.StudentRecords.Single(s =&gt;s.ID==selectedValue);</code></p>
  
  <p>Where does that error come from and what do I need to change to fix that error?      </p>