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

    How to update lookup fields in sharepoint list

    Hi,

    I have a list that contains 3 lookup fields , i was trying to update the list item through custom webpart, but only one lookup field is getting updated rest fields are empty.

    here the code iam using:

    SPListItem itms = list.AddItem();
    web.AllowUnsafeUpdates = true;
    SPFieldLookupValue value1= new SPFieldLookupValue(Convert.ToInt32(row.Cells[0].Text) ,row.Cells[0].Text);
    itms["ClientID"] = value1;

    SPFieldLookupValue value2=new SPFieldLookupValue(Convert.ToInt32(row.Cells[1].Text), row.Cells[1].Text);
    itms["ManagerID"] = value2;

    SPFieldLookupValue value3 = new SPFieldLookupValue(Convert.ToInt32(row.Cells[2].Text), row.Cells[2].Text);
    itms["RecruiterID"] = value3;

    SPFieldLookupValue value4 = new SPFieldLookupValue(Convert.ToInt32(drps.SelectedValue.ToString()), drps.SelectedValue.ToString());
    itms["RequirementID"] = value4;

    itms.Update();
    web.AllowUnsafeUpdates = false;

    only the ClientID is getting updated


    what could be the reason please help.



    thanks

    Ginnas
  • #744589
    Hi ginnas,

    Can you please check that field name's are correct or not. "ClientID", "ManagerID", "RecruiterID"," RequirementID", I doubted that the field names are wrong that's the reason it won't updated properly. Please check and get back if you still facing the issue..

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #744609
    Hi naveen,

    Thanks for the response, all the fields are correct only is there any other possibility to occur the error like this.

    Thanks
    Ginnas


  • Sign In to post your comments