I'm trying to modify some of the XSL in a DataForm web part (thanks to migration from SP2007 -> SP2010), and I'm able to checkout the file (several files, eventually), find the relevant XSL, and replace it with the SP2010 equivalent.
But what's not working is attempting to save the changes.
The code looks roughly like this:
currentPage = CheckPageOut(...);
web.AllowUnsafeUpdates = true;
using (SPLimitedWebPartManager wm = web.GetLimitedWebPartManager())
{
SPLimitedWebPartCollection wpc = wm.WebParts;
for (int i = wpc.Count - 1; i >= 0; i--)
{
Microsoft.SharePoint.WebPartPages.WebPart mwp = wpc[i] as
Microsoft.SharePoint.WebPartPages.WebPart;
// ... find and replace XSL bits
wm.SaveChanges(mwp);
}
wm.Web.Dispose();
}
currentPage.Web.Update();
CheckPageBackIn(currentPage);
The call to SPLimitedWebPartManager.SaveChanges always triggers an exception that says "The file is currently checked out or locked for editing by another user.". This is the case no matter who I'm logged in as (even when I supply SystemUser's SPUserToken).
What could I be doing wrong?
Thanks in advance
Josh