here's the code
using (SPSite site = new SPSite("https://mysite.com/Ting/default.aspx"))
{
using (SPWeb web = site.OpenWeb())
{
SPList SourceList = web.Lists["Record1"];
SPList TargetList = web.Lists["Record2"];
SourceList.Fields.AddLookup("Certificate", TargetList.ID, false);
SPFieldLookup lkp = (SPFieldLookup)SourceList.Fields["Certificate"];
lkp.LookupField = TargetList.Fields["Name"].InternalName;
lkp.Update();
for (int i = 0; i < 3; i++)
{
SPView view = SourceList.Views[i];
view.ViewFields.Add("Certificate");
view.Update();
}
}
}
what I am doing here is creating a lookup field in a already created Sharepoint list, Problem is, when I add a to Source List, it shows me all the certificates in a drop down choice, but when i see all the items view, it shows certificate names as " 1_.000" and increment by the number of items i add to the list, even if i use same certificate.
sounds like a logical problem to me :/