| 5/1/2008 2:48:35 PM |
I have a many to many relationship created in my database with FK constraints to the related tables. I am trying to add to the list of objects for each item selected in a check box. See code below. I am getting a null object reference to the focus.TitleList and I don't understand why. I created a new instance to my focus object so that is not null, but why would the TitleList be null?
focus = new UnitVisitTracking.Business.Focus();
foreach (ListItem item in this.TitleList.Items)
{
if (item.Selected)
{
UnitVisitTracking.Business. Title newTitle = UnitVisitTracking.Business.Title.RetrieveByKey(Convert.ToInt32(item.Value));
if (newTitle != null)
{ focus.TitleList.Add(newTitle); }
}
}
|