Last Updated: 07 Mar 2019 12:03 by ADMIN
Created on: 07 Mar 2019 12:02
Category: Grid
Type: Bug Report
RadGrid with Virtualization calls the NeedDataSource event at every postback with RebindReason ExplicitRebind

When virtualization is enabled for RadGrid, NeedDataSource is called at every Post back with RebindReason = ExplicitRebind, regardless of the event target.

Steps to reproduce:

Use the following Code snippets for the runnable sample and debug the NeedDataSource event while doing post backs using other controls. For instance, you can use the RadButton1 from these snippets to make a standard Post Back.


        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">

        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default"></telerik:RadAjaxLoadingPanel>
        <telerik:RadButton runat="server" ID="RadButton1" Text="Postback" AutoPostBack="true" />

        <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="false" Width="800px" OnNeedDataSource="RadGrid1_NeedDataSource">
            <MasterTableView AutoGenerateColumns="true" DataKeyNames="OrderID">
                <Scrolling AllowScroll="true" />
                <Virtualization EnableVirtualization="true" InitiallyCachedItemsCount="500" ItemsPerView="200" RetrievedItemsPerRequest="200" LoadingPanelID="RadAjaxLoadingPanel1" />


    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        RadGrid1.DataSource = OrdersTable();

    private DataTable OrdersTable()
        DataTable dt = new DataTable();

        dt.Columns.Add(new DataColumn("OrderID", typeof(int)));
        dt.Columns.Add(new DataColumn("OrderDate", typeof(DateTime)));
        dt.Columns.Add(new DataColumn("Freight", typeof(decimal)));
        dt.Columns.Add(new DataColumn("ShipName", typeof(string)));
        dt.Columns.Add(new DataColumn("ShipCountry", typeof(string)));

        dt.PrimaryKey = new DataColumn[] { dt.Columns["OrderID"] };

        for (int i = 0; i < 10000; i++)
            int index = i + 1;

            DataRow row = dt.NewRow();

            row["OrderID"] = index;
            row["OrderDate"] = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0).AddHours(index);
            row["Freight"] = index * 0.1 + index * 0.01;
            row["ShipName"] = "Name " + index;
            row["ShipCountry"] = "Country " + index;


        return dt;