I am creating a custom list programmatically. List has one Lookup field. Here is my code sample how I am creating LookUp field.
oList.Fields.AddLookup("Parent", oListGuid, false);
SPFieldLookup fldLookUp = (SPFieldLookup)oList.Fields["Parent"];
fldLookUp.LookupField = oList.Fields["Parent"].InternalName;
fldLookUp.Update();
SPFieldLookupValueCollection lkpValues = new SPFieldLookupValueCollection();
lkpValues.Add(new SPFieldLookupValue(0,"None"));
lkpValues.Add(new SPFieldLookupValue(1, "Parent1"));
lkpValues.Add(new SPFieldLookupValue(0, "Parent2"));
I am not sure how to assign value collection to my look up field.
I tried something like oListItem["Parent"]=lkpValues ;
But it gives me an error
Error occurred in deployment step 'Activate Features': Invalid data has been used to update the list item. The field you are trying to update may be read only.
Please help me on this.
Regards VB