I need a drop down list to display a current set of active cases, but I get an error whenever it returns with more than one case. The code looks like this:
masterCaseList.DataSource = MasterCasesBLL.GetAllMasterCases(false)
.Where(x => x.MainContact.MainContact == true)
.Select(x => new { MainContact = x.MainContact.MainContactLabel, index = x.ID })
.ToList();
masterCaseList.DataValueField = "index";
masterCaseList.DataTextField = "MainContact";
masterCaseList.DataBind();
And the error I get is:
System.NullReferenceException: Object reference not set to an instance of an object. at PCM_UI.manageReferrals.b__2(CaseDTO x) in c:\Users\Public\Documents\PathFinder Case Manager\PCM.UI\pages\manageReferrals.aspx.cs:line 33 at System.Linq.Enumerable.WhereSelectListIterator
2.MoveNext() at System.Collections.Generic.List
1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable
1 source) at PCM_UI.manageReferrals.Page_Load(Object sender, EventArgs e) in c:\Users\Public\Documents\PathFinder Case Manager\PCM.UI\pages\manageReferrals.aspx.cs:line 33