SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
  1. First Group By is not working (however the second file subcategory Group By works)
  2. The OrderBy is not working
  3. Show all items without folder is not working

Any ideas??

private static void CustomView(SPWeb web, SPList spList)
    SPViewCollection oViewCollection = spList.Views;
    string strViewName = "Custom_View";
    System.Collections.Specialized.StringCollection viewFields = new System.Collections.Specialized.StringCollection();
    viewFields.Add("File Type");
    viewFields.Add("File Date");
    viewFields.Add("File Number");           
    //string strQuery = "<OrderBy><FieldRef Name=\"LinkFilenameNoMenu\" /></OrderBy>";  //works

    string strQuery = "<GroupBy Collapse=\"TRUE\" GroupLimit=\"100\">" +
                        "<FieldRef Name=\"File Category\"/>" +
                        "<FieldRef Name=\"File Subcategory\"/>" +
                        "</GroupBy>" +
                        "<OrderBy>" +
                        "<FieldRef Name=\"LinkFileName\"/>" +

    oViewCollection.Add(strViewName, viewFields, strQuery, 100, true, true);    

    SPView view = spList.Views["Front_Page"];
    view.Scope = SPViewScope.Recursive;
share|improve this question

Problem Solved.

  1. Used LinkFilenameNoMenu for order by and it works.
  2. Used File_x0020_Category instead of File Category in group by and the group by working.
  3. Added view.update() to make recursive working.


share|improve this answer

Your Answer


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