Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Adding an Attachment to a List Item Programmatically in SharePoint


25 Jun 2010   #1

windows
 
 
Adding an Attachment to a List Item Programmatically in SharePoint

As we can have multiple attachments against a list item, it has always been a requirement to fetch these attachments and get it displayed within a custom webpage.

Below is code snippet in c#.net for fetching all the attachements for a specific list item.
try
{
// Set the Site Url
SPSite objSite = new SPSite("http://Testsite/");

using (SPWeb objWeb = objSite.OpenWeb())
{
objWeb.AllowUnsafeUpdates = true;

// Get the List
SPList objList = objWeb.Lists["MyList"];

// Get the item by ID
SPListItem objItem = objList.GetItemById(1);

// Get the attachments of the item
SPAttachmentCollection objAttchments = objItem.Attachments;

Thanks,
Bijayani
Sharepoint Migration Services

My System SpecsSystem Spec
.

Reply

 Adding an Attachment to a List Item Programmatically in SharePoint




Thread Tools



Similar help and support threads for2: Adding an Attachment to a List Item Programmatically in SharePoint
Thread Forum
How to delete item from Open With list? Customization
Problem with adding new item in Visual Studio Project Software
Solved Can you move item in your device manager up or down the list? General Discussion
Adding item Open file list General Discussion
Windows 8 Feature Wish List Item: the Uberbar News
Adding a context menu item to Windows 7 Customization
I like the open item list from the Taskbar General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 07:00 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33