I am working with a RadGrid that, in the past, was simply bound to an ObjectContainerDataSource. Past, completely working grid:
In the past few days, I've been fussing with this grid in order to change the data load from on page load to an ajax request. In the process of doing this, I needed to change the data binding method to the more advanced "NeedDataSource" binding. New grid:
With the NeedDataSource method:
Simple, and yet, suddenly my ObjectContainerDataSource (OCDS) is hitting the database 3 times instead of one. After some debugging, for some reason the OCDS is firing the selecting event 3 times (twice with the same selectingeventarguments and once with a different set). Please note, that no matter what the configuration.deferredload setting evaluates to (true or false), the selecting event is fired three times. Also note, the NeedDataSource method itself is not called three times, just the OCDS selecting method (though I cannot for the life of me pinpoint why).
So I'm wondering - is OCDS not supported with advanced data binding? Is there something else I'm missing (obvious or obscure)?
Any help of any kind greatly appreciated. Just a note, I've scrubbed all ID's and method names in the code blocks above to remove any identifying information. My grid is NOT named RadGrid, promise.
<telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" AllowAutomaticUpdates="True" OnItemCommand="RadGrid_ItemCommand" OnItemDataBound="RadGrid_ItemDataBound" AllowPaging="true" PageSize="10" OnPageSizeChanged="GridPageSizeChanged" AutoGenerateColumns="false" OnSortCommand="RadGrid_SortCommand" AllowMultiRowSelection="true" OnItemCreated="RadGrid_ItemCreated" DataSourceID="RequestMasterDataSource" EnableViewState="true" > <ExportSettings HideStructureColumns="true" /> <MasterTableView TableLayout="Fixed" RetrieveDataTypeFromFirstItem="true" CommandItemDisplay="Top"> <CommandItemSettings ShowExportToExcelButton="false" ShowAddNewRecordButton="false" ShowRefreshButton="false" /> </MasterTableView> <ClientSettings> <ClientEvents OnRowDblClick="SendSelectedRowToParent"></ClientEvents> <Selecting AllowRowSelect="True"></Selecting> <Scrolling AllowScroll="false"></Scrolling> <ClientMessages DragToGroupOrReorder="Drag to group" /> <Resizing ResizeGridOnColumnResize="True" AllowRowResize="True" AllowColumnResize="True"> </Resizing> </ClientSettings> <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"> </HeaderContextMenu> </telerik:RadGrid>In the past few days, I've been fussing with this grid in order to change the data load from on page load to an ajax request. In the process of doing this, I needed to change the data binding method to the more advanced "NeedDataSource" binding. New grid:
<telerik:RadGrid ID="RadGrid" runat="server" GridLines="None" AllowAutomaticUpdates="True" OnItemCommand="RadGrid_ItemCommand" OnItemDataBound="RadGrid_ItemDataBound" AllowPaging="true" PageSize="10" OnPageSizeChanged="GridPageSizeChanged" AutoGenerateColumns="false" OnSortCommand="RadGrid_SortCommand" AllowMultiRowSelection="true" OnItemCreated="RadGrid_ItemCreated" OnNeedDataSource="RadGrid_NeedDataSource" EnableViewState="true" > <ExportSettings HideStructureColumns="true" /> <MasterTableView TableLayout="Fixed" RetrieveDataTypeFromFirstItem="true" CommandItemDisplay="Top"> <CommandItemSettings ShowExportToExcelButton="false" ShowAddNewRecordButton="false" ShowRefreshButton="false" /> </MasterTableView> <ClientSettings> <ClientEvents OnRowDblClick="SendSelectedRowToParent"></ClientEvents> <Selecting AllowRowSelect="True"></Selecting> <Scrolling AllowScroll="false"></Scrolling> <ClientMessages DragToGroupOrReorder="Drag to group" /> <Resizing ResizeGridOnColumnResize="True" AllowRowResize="True" AllowColumnResize="True"> </Resizing> </ClientSettings> <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"> </HeaderContextMenu> </telerik:RadGrid>protected void RadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { if (configuration.DeferredLoad) { if (Page.IsPostBack) { RadGrid.DataSource = RequestMasterDataSource; } }else { RadGrid.DataSource = RequestMasterDataSource; } } Simple, and yet, suddenly my ObjectContainerDataSource (OCDS) is hitting the database 3 times instead of one. After some debugging, for some reason the OCDS is firing the selecting event 3 times (twice with the same selectingeventarguments and once with a different set). Please note, that no matter what the configuration.deferredload setting evaluates to (true or false), the selecting event is fired three times. Also note, the NeedDataSource method itself is not called three times, just the OCDS selecting method (though I cannot for the life of me pinpoint why).
So I'm wondering - is OCDS not supported with advanced data binding? Is there something else I'm missing (obvious or obscure)?
Any help of any kind greatly appreciated. Just a note, I've scrubbed all ID's and method names in the code blocks above to remove any identifying information. My grid is NOT named RadGrid, promise.