title: How to add pagination to <asp:GridView>
body: <p>I'm trying to add pagination to an <code>&lt;asp:GridView&gt;</code> in an application I'm working on.</p>
  
  <p>This is what I've tried before running into an issue.</p>
  
  <pre><code>&lt;asp:LinqDataSource ID="Contacts" ContextTypeName="Xrm.XrmServiceContext" TableName="ContactSet" runat="server"/&gt;
  
      &lt;asp:GridView ID="gvContacts" DataSourceID="Contacts" AutoGenerateColumns="false"
          runat="server" GridLines="None" CssClass="table table-hover table-striped"
          UseAccessibleHeader="true" OnPreRender="gvContacts_PreRender" AllowPaging="true" &gt;
  
          &lt;!-- irrelevant grid view content --&gt;
  
      &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>If you ignore the the <code>AllowPaging="true"</code>, everything works fine (without the pagination feature). As soon as I include <code>AllowPaging="true"</code> I get the following error:</p>
  
  <blockquote>
    <p>System.NotSupportedException: The method 'Count' is not supported.</p>
  </blockquote>
  
  <p>How can I add pagination (size = 50) to my <code>&lt;asp:GridView&gt;</code>? Am I on the wrong track or is there something I'm missing?</p>