My SharePoint list has a column that allows multiple lookup values. My C# control (within a webpart) allows the user to make multiple selections from a list box. I split these values into an array - each array member being a selected value that needs to be updated in the same SPListItem column.
I know that the selections are being passed in properly from the list box - I just need to add this group of values to the same column in the SPListItem.
Where am I going wrong?
SPFieldLookupValueCollection MyCollection = new SPFieldLookupValueCollection();
for (int i = 0; i < MyArrayOfSelections.Length; i++)
{
if (MyLookupList["LookupColumn"].ToString() == MyArrayOfSelections[i].ToString())
{
MyID = int.Parse(MyLookupList[i]["ID"].ToString());
SPFieldLookupValue thisSelection = new SPFieldLookupValue(MyID,MyArrayOfSelections[i].ToString());
MySubCollection.Add(thisSelection);
}
}
ListIWantToUpdate["ColumnWithMultipleLookupSelections"] = SubCollection;
ListIWantToUpdate.Update();
site.Update();