Linq error RRS feed

  • Question

  • Can I have some insight on this error? 

    I get the error in line 2 below:

    1 DoorScheduleDataContext db = new DoorScheduleDataContext();     
    2 PeopleInCategory pic = db.PeopleInCategories.Single(p => p.CategoryID == int.Parse(ddlCategories.SelectedValue));   

    Here is the error:

    System.InvalidOperationException was unhandled by user code
      Message="Sequence contains more than one element"

    Basically I am trying to create a PeopleInCategory object from a CategoryID (a DropDownList value).

    PeopleInCategory was created with LINQ To SQL designer.

    Thanks for any help.

    Wednesday, January 7, 2009 2:25 PM