Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a document library of 179 documents, and I want to reorder them. I have this code to try swapping the first two documents

        bool u = sharepoint.library.Ordered;
        if (!u)
        {
            sharepoint.library.Ordered = true;
            sharepoint.library.Update();
        }

        bool[] g = new bool[179];
        int[] h = new int[179];
        for (var j = 0; j < 179; j += 1)
        {
            g[j] = false;
            h[j] = 0;
        }
        g[0] = true;
        g[1] = true;
        h[0] = 1;
        h[1] = 0;

        sharepoint.library.Items.ReorderItems(g,h,0);

But it gives this error:

(5/8/2013 9:15:15 PM) - Error Message: Specified method is not supported. Stacktrace: at Microsoft.SharePoint.SPList.set_Ordered(Boolean value)

Does anyone know why this happens?

share|improve this question

1 Answer 1

The problem might be that you try to move all documents to place 0, except for the one in position 1 of the h array.

bool[] g = new bool[179];
int[] h = new int[179];

for (var j = 0; j < 179; j++)
{
    g[j] = false;
    h[j] = j;
}

g[0] = true;
g[1] = true;
h[0] = 1;
h[1] = 0;

See the last answer in this link for a working example.

UPDATE: Per the MSN documentation on SPList.Ordered, this is not supported for SPDocumentLibrary among other:

The Ordered property is true by default for links lists. Setting this property to true for a list of base type Survey, IssueTracking, DocumentLibrary, or DiscussionBoard throws a System.NotSupportedException exception.

So ordering is just not supported for Document Libraries unfortunately.

share|improve this answer
    
I tried this, but it didn't work. Is it because I'm using a document library instead of a list? –  omega May 9 '13 at 14:23
    
If you did try the exact code from the link them that might be the case, I do see now that he sets h[j]=j+1 for each item unlike you, does that help? –  Robert Lindgren May 9 '13 at 14:26
    
I tried both versions, and neither worked. –  omega May 9 '13 at 14:31
    
I solved the error through by not calling the .Ordered method, but now the rest of the code works without errors, but there is no effect on the list, like the items are still in the same order basically. –  omega May 9 '13 at 14:43
    
Just found some interested documentation about this on MSDN, see my updated answer. Sorry to tell you, but it do indead seem unsupported och some list types, including Document Library. –  Robert Lindgren May 9 '13 at 15:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.