Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0 C# C#4.0 Sharepoint , +
 public void Button1_Click(object sender, EventArgs e)
        {
            SPWeb mySite = SPContext.Current.Web;
            SPListItemCollection listItems = mySite.Lists["doneee"].Items;
            SPListItem item = listItems.Add();
 
            item.Update();
        }
        void documentAttachmentInSPList(SPListItem item)
        {
            SPListItem spListItem = item;
            string LISTNAME = spListItem.ParentList.Title;
            if (!string.IsNullOrEmpty(fileupload.FileName))
            {
                string fileExtension = fileupload.FileName.Substring(fileupload.FileName.IndexOf("*"));
                for (int i = 0; i < spListItem.Attachments.Count; i++)
                {
                    if ((spListItem.Attachments[i] != null)
                     && (spListItem.Attachments[i].Equals("FILENAME" + fileExtension)))
                    {
                        spListItem.Attachments.Delete("FILENAME" + fileExtension);
                        break;
 
                    }
                }
                spListItem.Attachments.Add("FILENAME" + fileExtension, fileupload.FileBytes);
                string attachmentURL = Request.Url.Scheme + "://" + Request.Url.Authority
                + "/Lists/" + LISTNAME + "/Attachments/" + spListItem.ID + "/";
                spListItem["Attached File"] = attachmentURL + "FILENAME" + fileExtension + ", View FILE";
 

            }
 

 

 

 

 

 

 
I created a button and fileupload control so that when i browse the file and click on button file should go intot the customlist.By using above code i am not able to upload file.
Posted 28-Nov-12 0:01am
Kurac1841

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web01 | 2.8.150305.1 | Last Updated 28 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100