Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should not call <code>commentRadGrid.DataBind()</code> inside <code>commentRadGrid_NeedDataSource</code> event.</p> <p><a href="http://www.telerik.com/help/aspnet-ajax/grid-advanced-data-binding.html" rel="nofollow">Advanced Data-binding (using NeedDataSource event)</a></p> <blockquote> <p>You should never call the Rebind() method in a NeedDataSource event handler.You should never call DataBind() as well when using advanced data binding through NeedDataSource. For Microsoft GridView-like data binding, see Simple Data-binding.</p> </blockquote> <h2>Update:</h2> <p>If you set <code>AllowCustomPaging="True"</code>, you will need to provider <code>VirtualItemCount</code>.</p> <p>It basically means you are giving RadGrid to maximum 100 rows (<code>PageSize="100"</code>) although you have a million records. Therefore, RadGrid need to know how many total records you have in order to display pagination.</p> <p><em><strong>Note:</em></strong> If you have only few records, you want to provide all records to RadGrid. If so, you do not need both <code>AllowCustomPaging="True"</code> and <code>VirtualItemCount</code>.</p> <p>Here is the sample example -</p> <pre><code>&lt;asp:ScriptManager ID="ScriptManager1" runat="server" /&gt; &lt;telerik:RadGrid runat="server" ID="commentRadGrid" AllowFilteringByColumn="true" AutoGenerateColumns="True" AllowPaging="true" OnPageIndexChanged="commentRadGrid_PageIndexChanged" OnNeedDataSource="commentRadGrid_NeedDataSource" PageSize="100" Skin="Default" AllowSorting="true" ShowStatusBar="true" AllowCustomPaging="True" GridLines="none"&gt; &lt;/telerik:RadGrid&gt; &lt;asp:Button runat="server" ID="OlderCommentsButton" OnCommand="OlderCommentsButton_Click" Text="Post Back" /&gt; public class User { public string FirstName { get; set; } public string LastName { get; set; } } protected void commentRadGrid_NeedDataSource( object sender, GridNeedDataSourceEventArgs e) { var users = new List&lt;User&gt; { new User {FirstName = "John", LastName = "Doe"}, new User {FirstName = "Jenny", LastName = "Doe"}, }; commentRadGrid.DataSource = users; commentRadGrid.MasterTableView.VirtualItemCount = users.Count; } protected void OlderCommentsButton_Click(object sender, EventArgs e) { try { commentRadGrid.Rebind(); } catch (Exception ex) { } } protected void commentRadGrid_PageIndexChanged( object sender, GridPageChangedEventArgs e) { } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload