You must Sign In to post a response.
  • Category: Sharepoint

    How to create lookup in sharepoint using C#

    how to create lookup fields using C# in sharepoint. ?
  • #756742

    Use the below code to create look up in SharePoint List.
    //Source list to add lookup column
    SPList srcList=Web.lists["My List"];
    //Lookup list
    SPList lookUpList = web.Lists["User Roles"];
    //Creeate Lookup column
    srcList.Fields.AddLookup("Lookup Column", lookUpList .ID, false);
    //Assign reference column from lookup list

    SPFieldLookup lkp = (SPFieldLookup)srcList.Fields["Lookup Column"];
    lkp.LookupField = lookUpList .Fields["Title"].InternalName;

    Thanks and Regards,
    M.Anandha Babu

  • Sign In to post your comments