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

Anyone that knows How to put image attachment to image control (to display)

if (FileUpload_Pic.PostedFile != null && FileUpload_Pic.HasFile)
                        {
                            Stream fStream = FileUpload_Pic.PostedFile.InputStream;

                            byte[] contents = new byte[fStream.Length];
                            fStream.Read(contents, 0, (int)fStream.Length);
                            fStream.Close();
                            fStream.Dispose();

                            SPAttachmentCollection attachments = item.Attachments;
                            string fileName = Path.GetFileName(FileUpload_Pic.PostedFile.FileName);
                            attachments.Add(fileName, contents);

                            //listItem["Attached FileName"] = fileName; // store the name of the file in a column for future requirements
                            item.Update();
                        }

                        if (FileUpload_Doc.PostedFile != null && FileUpload_Doc.HasFile)
                        {
                            Stream fStream = FileUpload_Doc.PostedFile.InputStream;

                            byte[] contents = new byte[fStream.Length];
                            fStream.Read(contents, 0, (int)fStream.Length);
                            fStream.Close();
                            fStream.Dispose();

                            SPAttachmentCollection attachments = item.Attachments;
                            string fileName = Path.GetFileName(FileUpload_Doc.PostedFile.FileName);
                            attachments.Add(fileName, contents);




                        }

// This is my code that i put in a list , but i would like to learn to put the same pictures in an Image Control Using Attachment that i upload to the list.

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.