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;
http://www.mindfiresolutions.com/Adding-an-Attachment-to-a-List-Item-Programmatically-in-SharePoint-478.php
Guid wrote:
How to create a document library view programmatically
11-Sep-08
Hi there
i would like to create a view from an existing document library
programmatically using a sharepoint feature. Is there a solution for that?
I'm thankful for any information. Furthermore, I would like to add some code
below the document library in the new created view. There must be a way to do
all this programmatically, isn't it? The view is not more than an aspx file
in the view-folder of the document library. Thanks in advance for any helpful
information
Kind regards,
Previous Posts In This Thread:
On Thursday, September 11, 2008 3:06 PM
Guid wrote:
How to create a document library view programmatically
Hi there
i would like to create a view from an existing document library
programmatically using a sharepoint feature. Is there a solution for that?
I'm thankful for any information. Furthermore, I would like to add some code
below the document library in the new created view. There must be a way to do
all this programmatically, isn't it? The view is not more than an aspx file
in the view-folder of the document library. Thanks in advance for any helpful
information
Kind regards,
On Saturday, September 13, 2008 7:04 AM
SundarNarasimanMV wrote:
Guido,You can programmatically create SharePoint Views.
Guido
You can programmatically create SharePoint Views. There is class called
SPViewCollection and there is a method called Add. You can leverage this to
programmatically create SP Views
http://blogs.msdn.com/sowmyancs/archive/2008/03/15/programmatically-create-a-view-custom-view-of-a-list-and-change-the-view.asp
--
---
Sundar Narasiman
http://msmvps.com/blogs/sundar_narasiman
"Guido" wrote:
On Thursday, May 06, 2010 9:30 AM
eliza sahoo wrote:
Create and Update Views Programmatically in SharePoint
using (SPSite oSPsite = new SPSite("http://website_url/"))
{
oSPsite.AllowUnsafeUpdates = true;
using (SPWeb oSPWeb = oSPsite.OpenWeb())
{
oSPWeb.AllowUnsafeUpdates = true;
/* get the list instance by list name */
SPList list = oSPWeb.Lists["List_Name"];
/* ======== Part I (create a view) ======== */
// add the field names to the string collection
StringCollection strViewFields = new StringCollection();
strViewFields.Add("FullName");
strViewFields.Add("Address");
strViewFields.Add("City");
strViewFields.Add("State");
// create a standard view with the set of fields defined in the collection
list.Views.Add("View_Name", strViewFields, String.Empty,
100, true, false, SPViewCollection.SPViewType.Html, false);
/* ==== End Part I ==== */
/* ==== Part II (add fields to an existing view) ==== */
// get the view instance by view display name
SPView view = list.Views["Existing_View_Name"];
// add fields to the view
view.ViewFields.Add("Zip");
view.ViewFields.Add("Country");
// update view for new fields
view.Update();
/* ==== End Part II ==== */
/* update the list */
list.Update();
oSPWeb.AllowUnsafeUpdates = false;
}
oSPsite.AllowUnsafeUpdates = false;
}
http://www.mindfiresolutions.com/sharepoint-development.htm
On Tuesday, June 08, 2010 7:23 AM
Bijayani Baijayanti wrote:
Programatically adding a document to document library in SharePoint
Hi,
I am sharing a tips on "Programatically adding a document to document library in SharePoint".
In some cases we need to add documents to the doument library programatically, the code snippet below demonstrates how to add a document to the document library .
using (SPSite objSite = new SPSite("urlAddress"))
{
objSite.AllowUnsafeUpdates = true;
using (SPWeb oSPWeb = objSite.OpenWeb())
{
Hope you find this tips useful and of assistance. For more information on this tips, please visit: http://www.mindfiresolutions.com/Programatically-adding-a-document-to-document-library-in-SharePoint-709.php
Thanks,
Bijayani
Submitted via EggHeadCafe - Software Developer Portal of Choice
Producer/Consumer Queue and BlockingCollection in C# 4.0
http://www.eggheadcafe.com/tutorials/aspnet/7d10d73c-321c-446e-8b6d-b81ee8d9b314/producerconsumer-queue-and-blockingcollection-in-c-40.aspx