Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 :/

share|improve this question

1 Answer 1

up vote 0 down vote accepted

The Reason was because, both Sharepoint builtin Forms were calling different attributes of the lookup field.

In order to finish my task, i created a event handler that, copies name field to Title field, so that later on i can use it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.