0

I am able to easily added a document to the site. I am able to fill in one and only one of the columns on the document library. I want to need to be able to add more than one in the selection. It is only adding the last one from the check box list. I want to add more than one metadata tag to the document. I have configured the document library to accept more than one tag in the column.

if (FU1.PostedFile != null)   
                {    
                if (FU1.PostedFile.ContentLength > 0)     
                {   
                    Stream fileStream = FU1.PostedFile.InputStream;      
                    byte[] byt = new       byte[Convert.ToInt32(FU1.PostedFile.ContentLength)];   
                    fileStream.Read(byt, 0,       Convert.ToInt32(FU1.PostedFile.ContentLength));    

                    fileStream.Close();     

                    using (SPSite site = new SPSite(SPContext.Current.Site.Url))    

                    {   
                        using (SPWeb webcollection = site.OpenWeb())   
                        {      
                            SPFolder myfolder = webcollection.Folders["collecteddocuments"];   
                            webcollection.AllowUnsafeUpdates = true;   
                            SPFile file = myfolder.Files.Add(System.IO.Path.GetFileName(FU1.PostedFile.FileName), byt);
                            SPListItem item = file.Item;
                            //StringBuilder sb = new StringBuilder();
                            //int metadataCount = this.CblDocumentMetadata.Items.Count;
                            //int count = 0;
                            foreach (var q in this.CblDocumentMetadata.Items)
                            {
                                item["Document Type"] = q.ToString();

                            }
                            item.Update();
                        }
                    }
                }
            }

1 Answers1

0

Based on your code, it looks like you are setting the "Document Type" to each item in CblDocumentMetadata, and the last one will be the last one that gets set.

It is really unclear to me what are you actually trying to do here. Perhaps you can edit your question to clarify?

Doug Stalter
  • 733
  • 4
  • 11