Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am uploading document programically and passing lookup field value but its not get updated, how to handle this?

   using (var site = new SPSite("http://ussecavpdvrwk06/sites/TAS/"))
       {
           using (SPWeb web = site.OpenWeb())
                {
                    SPList sharedDocumentList = web.ServerRelativeUrl.Equals("/")
                              ? web.GetList(web.ServerRelativeUrl + "SharedDocuments")
                              : web.GetList(web.ServerRelativeUrl + "/" + "SharedDocuments");
                    Hashtable propertiesHash = new Hashtable
                        {
                            {"EYReverseLookupRelatedTasks", "3110112619"}//get_ID(web, "Lists/Tasks", "LinkTitle", "3110112619")}                                                 
                        }; 

                    byte[] strm = File.ReadAllBytes("C:\\xml\\XMLDATAFile.xml");
                    sharedDocumentList.RootFolder.Files.Add(sharedDocumentList.RootFolder.Url + "/" + "mydocxml", strm, propertiesHash, false);

                    web.AllowUnsafeUpdates = false;
                }
        }
share|improve this question

2 Answers

up vote 1 down vote accepted

For a lookup column you must provide the ID of the item you are referring to.

Thus if the item being lookup has an ID of 3 you must provide that in the hashtable, with lookups to multiple items you must provide the ID and the value separeted by ;# e.g.: 1;#First Item;#3;#THirdItem.

share|improve this answer

You need have to update the SPList object...

share|improve this answer
it's not working buddy. – Ayyappan.Anbalagan Nov 1 '11 at 6:15

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.