Limit datagrid items in asp.net c#
<p>I am using <code>DataGrid</code> in ASP.NET C# . I want to limit and control the <strong>number of items displayed</strong> in a <code>DataGrid</code> (I am forced to use this controller). </p>

<p>I know we can control using </p>

<ol>
<li><code>AllowPaging = "TRUE"</code> per page basis</li>
<li>Limit <code>DataSource</code> using <code>sql</code> query and then binding (<code>DataBind()</code>) it.</li>
</ol>

<p>But I don't want either. I want to run <code>sql</code> query once and get all data, then I must be able to display first 10 or 20 items depending on the requirements. </p>

<p>It's preferable if I could do it</p>

<ol>
<li>in code behind.</li>
<li>without page reload, if I increase the item size to 30 from 10</li>
</ol>

<p>Any kind of heads up in right path appreciated </p>