title: C# sharepoint how to retrieve list items from the specific view
body: <p>I want to retrieve all list items for the specific view. Now I can retrieve items but each time I have 22000 items. But in view Main I have only two items.</p>
  
  <p><a href="https://i.stack.imgur.com/8UIXR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8UIXR.png" alt="enter image description here"></a></p>
  
  <p>My code written based on other posts in Stackoverflow:</p>
  
  <pre><code>using (var ctx = new ClientContext("http://sp2.intranet.mmmm.net/LWW/Europe/Warsaw/loc/eng/"))
  {
        Web web = ctx.Web;
        var tasksList = web.Lists.GetByTitle("Collaboration-Intracompany");
  
        ctx.ExecuteQuery();
        Microsoft.SharePoint.Client.View view = tasksList.Views.GetByTitle("Main");
        ctx.Load(view);
        ctx.ExecuteQuery();
  
        CamlQuery camlQuery1 = new CamlQuery();
        camlQuery1.ViewXml = view.ViewQuery;
        // camlQuery1.ViewXml = @"&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;IsNotNull&gt;&lt;FieldRef Name='ID' /&gt;&lt;/IsNotNull&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;ViewFields&gt;&lt;FieldRef Name='ID' /&gt;&lt;/ViewFields&gt;&lt;/View&gt;";
        //camlQuery1.ViewXml = @"&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name=\'DisplayName\' /&gt;&lt;Value Type=\'Text\'&gt;Main&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;/View&gt;";
  
        ListItemCollection listItems = tasksList.GetItems(camlQuery1);
  
        ctx.Load(listItems);
        ctx.ExecuteQuery();
  }
  </code></pre>
  
  <p>My current ViewXml is below. It returns 4 items that have 'ENG In Progress'. But these 4 items are from different views. How to filter to return only items from view Main?</p>
  
  <pre><code>     CamlQuery camlQuery1 = new CamlQuery();
  
          camlQuery1.ViewXml = "&lt;View Name="{326A70B3-515F-4B92-B8FA-506865D192AF}" DefaultView="TRUE" Type="HTML" TabularView="FALSE" DisplayName="Main" Url="/LWW/Europe/Warsaw/loc/eng/Lists/CollaborationIntracompany/all.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/images/generic.png"&gt;
     &lt;ViewFields&gt;
        &lt;FieldRef Name="LinkTitle" /&gt;
        &lt;FieldRef Name="Task_x0020_Status" /&gt;
        &lt;FieldRef Name="Priority" /&gt;
        &lt;FieldRef Name="Assigned_x0020_To2" /&gt;
        &lt;FieldRef Name="Deadline" /&gt;
        &lt;FieldRef Name="Author" /&gt;
        &lt;FieldRef Name="Modified" /&gt;
        &lt;FieldRef Name="Activity" /&gt;
     &lt;/ViewFields&gt;
     &lt;Query&gt;
        &lt;Where&gt;
           &lt;Eq&gt;
              &lt;FieldRef Name="Task_x0020_Status" /&gt;
              &lt;Value Type="Text"&gt;ENG In Progress&lt;/Value&gt;
           &lt;/Eq&gt;
        &lt;/Where&gt;
     &lt;/Query&gt;
     &lt;Aggregations Value="Off" /&gt;
     &lt;RowLimit Paged="TRUE"&gt;300&lt;/RowLimit&gt;
     &lt;Mobile MobileItemLimit="3" MobileSimpleViewField="LinkTitle" /&gt;
     &lt;Toolbar Type="Standard" ShowAlways="TRUE" /&gt;
     &lt;XslLink Default="TRUE"&gt;main.xsl&lt;/XslLink&gt;
     &lt;ParameterBindings&gt;
        &lt;ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" /&gt;
        &lt;ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" /&gt;
     &lt;/ParameterBindings&gt;
  &lt;/View&gt;";
  
           ListItemCollection listItems = tasksList.GetItems(camlQuery1);
  </code></pre>
  
  <p>And when I remove query:</p>
  
  <pre><code> camlQuery1.ViewXml = ""
                          + "&lt;View Name='{326A70B3-515F-4B92-B8FA-506865D192AF}' DefaultView='TRUE' Type='HTML' TabularView='FALSE' DisplayName='Main' Url='/LWW/Europe/Warsaw/loc/eng/Lists/CollaborationIntracompany/all.aspx' Level='1' BaseViewID='1' ContentTypeID='0x' ImageUrl='/_layouts/images/generic.png'&gt;"
                          + "&lt;ViewFields&gt;"
                           + "&lt;FieldRef Name='LinkTitle' /&gt;&lt;FieldRef Name='Task_x0020_Status' /&gt;&lt;FieldRef Name='Priority' /&gt;&lt;FieldRef Name='Assigned_x0020_To2' /&gt;&lt;FieldRef Name='Deadline' /&gt;&lt;FieldRef Name='Author' /&gt;&lt;FieldRef Name='Modified' /&gt;&lt;FieldRef Name='Activity' /&gt;&lt;/ViewFields&gt;"
                          //  + "&lt;Query&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name='Task_x0020_Status' /&gt;&lt;Value Type='Text'&gt;ENG In Progress&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;/Query&gt;"
                             + "&lt;Aggregations Value='Off' /&gt;&lt;RowLimit Paged='TRUE'&gt;300&lt;/RowLimit&gt;&lt;Mobile MobileItemLimit='3' MobileSimpleViewField='LinkTitle' /&gt;"
                             + "&lt;Toolbar Type='Standard' ShowAlways='TRUE' /&gt;&lt;XslLink Default='TRUE'&gt;main.xsl&lt;/XslLink&gt;&lt;ParameterBindings&gt;"
                             + "&lt;ParameterBinding Name='NoAnnouncements' Location='Resource(wss,noXinviewofY_LIST)' /&gt;"
                             + "&lt;ParameterBinding Name='NoAnnouncementsHowTo' Location='Resource(wss,noXinviewofY_DEFAULT)' /&gt;&lt;/ParameterBindings&gt;&lt;/View&gt;";
  </code></pre>
  
  <p>It returns 300 items because the limit is 300. On the picutre you can see that view Main has only 4 positions. How to get exactly these 4 positions ?</p>