How do I update a sharepoint list using .net?

2019-07-30 08:15发布

问题:

I have a SharePoint list already created. I would like to occassionally update that list using a .NET application. How would I do that?

EDIT: This has to run on remote machines.

回答1:

pgb's answer is correct. It's pretty simple, really. One caveat with this is that the code that uses the SharePoint object model must be running on the SharePoint server itself -- not a remote machine. If you're trying to interact with a SharePoint list remotely, you would probably want to use web services. SharePoint 2007 has decent coverage of list manipulation in its built-in web services, but if you want more specific functionality you can always roll your own.

A good starting point for the roll-your-own option is here: http://msdn.microsoft.com/en-us/library/ms464040.aspx

The SDK docs for the Lists web service can be found at http://msdn.microsoft.com/en-us/library/lists.aspx



回答2:

Assuming you have your siteId and webId you can do something like this:

using (SPSite site = new SPSite(siteId))
{
    SPWeb web = site.OpenWeb(webId);
    SPList list = web.Lists["ListName"];

    // Manipulate your SPList here
}


回答3:

Please, look this questions:

  • Update Sharepoint List Item
  • Create Sharepoint List which has gantt view - programmatically