How do I update a sharepoint list using .net?
Asked Answered
D

3

1

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.

Doloritas answered 10/11, 2009 at 21:5 Comment(0)
P
3

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

Philemon answered 10/11, 2009 at 21:18 Comment(1)
Unfortunately running on the server isn't a viable option. Do you have more info one the built-in web services?Doloritas
F
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
}
Forfar answered 10/11, 2009 at 21:8 Comment(1)
I think you would also want to use using around the OpenWeb call.Philemon
L
2

Please, look this questions:

Literalism answered 10/11, 2009 at 21:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.