Prevent Auto Rebinding of Grid

15 posts, 0 answers
  1. Anurag
    Anurag avatar
    3 posts
    Member since:
    Apr 2014

    Posted 02 Apr 2014 Link to this post

    We are using a rad grid with edit form that opens in popup on the Edit event of each row. Currently grid refreshes each time the edit link is clicked and take time to open the Popup which is impacting the performance. Moreover if we cancel or close the popup
    (handled by cancel event) the grid again refreshes and this action also takes time which in fact should be immediate.

    Is there anyway to control the rebind of grid on these events.
    Structure of grid:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <telerik:AjaxSetting AjaxControlID="radGridComingSoon">
                    <telerik:AjaxUpdatedControl ControlID="radGridComingSoon">
    <telerik:RadAjaxLoadingPanel ID="comingSoonRadAjaxLoadingPanel" runat="server">

                                <telerik:RadGrid ID="radGridComingSoon" AllowSorting="True" AllowPaging="True" runat="server"
                                    OnItemCreated="radGridComingSoon_ItemCreated" OnItemDataBound="radGridComingSoon_ItemDataBound"
                                    GridLines="None" OnInsertCommand="radGridComingSoon_InsertCommand" OnUpdateCommand="radGridComingSoon_UpdateCommand"
                                    OnDeleteCommand="radGridComingSoon_DeleteCommand" OnItemCommand="radGridComingSoon_ItemCommand"
                                    BorderStyle="Solid" AutoGenerateColumns="false" AllowMultiRowEdit="false" EnableViewState="true"
                                    OnPreRender="radGridComingSoon_PreRender" AllowCustomSorting="true">
                                    <PagerStyle Mode="NextPrevAndNumeric" PrevPageText="Prev" FirstPageText="First" NextPageText="Next"
                                    <MasterTableView Width="100%" CommandItemDisplay="Top" DataKeyNames="StandardNumber"
                                        AutoGenerateColumns="false" InsertItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnFirstPage"
                                        <EditFormSettings InsertCaption="Add Coming Soon" CaptionFormatString="Edit Coming Soon">
                                            <PopUpSettings Modal="true" Width="742px" Height="1400px" ZIndex="201" />
                                            <table class="expandable standards-table">
                                                    <tr data-id='<%# Eval("ComingSoonId") %>'>
                                                        <td width="100px">
                                                            <asp:Label runat="server" ID="StandardNumberLabel" Text='<%# Eval("StandardNumber") %>'></asp:Label>
                                                              <td class="icon-column" width="50px" id="tdEditDeleteLink" runat="server">
                                                            <asp:LinkButton ID="btnUpdateEdited" runat="server" CommandName="Edit" CssClass="Edit-Summary"><i class="icon edit"></i></asp:LinkButton>
                                                            <asp:LinkButton ID="lnkBtnDelete" runat="server" CommandName="Delete" CssClass="delete"><i class="icon remove delete"></i></asp:LinkButton>
                                                            <asp:Label runat="server" ID="lblChange" Text='<%# Eval("ComingSoonId") %>' CssClass="hide"></asp:Label>
                                            <telerik:GridTemplateColumn HeaderText="Standard No." SortExpression="StandardNumber"
                                                UniqueName="StandardNumber" DataField="StandardNumber" ItemStyle-CssClass="ColorClass">
                                            <telerik:GridTemplateColumn HeaderText="ComingSoonId" SortExpression="ComingSoonId"
                                                UniqueName="ComingSoonId" DataField="ComingSoonId" Display="false" EditFormHeaderTextFormat="">
                                                No records to display</div>
                                        <EditFormSettings EditFormType="Template">
                                                <div class="modal coming-soon-modal">
                                                    <h3 class="brand modal-sub-title">
                                                        Brand: <strong>'<%#strBrandName %>'</strong></h3>
                                                    <div class="modal-form">
                                                            <asp:TextBox ID="txtCompDate" runat="server" CssClass="datepicker"></asp:TextBox>
                                                            <asp:Button ID="btnUpdate" CssClass="btn" Text='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "Insert", "Update") %>'
                                                                runat="server" CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update")%>'>
                                                            <asp:Button ID="btnCancel" Text="Cancel" CssClass="cancel" runat="server" CausesValidation="False"
                                        <CommandItemSettings AddNewRecordText="Add new record" AddNewRecordImageUrl="/_layouts/images/HBSImages/add-record-icon.gif"
                                            RefreshText="Refresh" RefreshImageUrl="/_layouts/images/HBSImages/refresh-icon.gif"
                                        <ClientEvents OnRowDblClick="RowDblClick"></ClientEvents>
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 03 Apr 2014 in reply to Anurag Link to this post

    Hi Anurag,

    The commands like Edit, Update, Cancel etc grid commands make an implicit call to the Rebind() method of RadGrid in order to refresh the control's content and fetch the latest information from the grid source. Take a look at this article to more about Commands that invoke Rebind() implicitly.
    You can check this topics under performance to have grid performance optimizations.

  3. Anurag
    Anurag avatar
    3 posts
    Member since:
    Apr 2014

    Posted 03 Apr 2014 Link to this post

    Hi Princy,

    Is there any way to prevent the grid from rebinding itself. I mean the grid should  rebind only in scenarios where i want to get it rebinded thus reducing the database calls. I mean there is no need to bind the grid on edit and cancel event in the above example. how to handle this???

    Anurag Chauhan
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 04 Apr 2014 in reply to Anurag Link to this post

    Hi Anurag,

    You may try to disable the ViewState. As mentioned in the documentation, when RadGrid's ViewState is turned off, the NeedDataSource event does not fire after any of the commands. If you want to make the event fire in such scenarios, you need to first set RadGrid's DataSource to null/Nothing and then call Rebind(). Have a look at this article on Rebind grid on command/postback event with EnableViewState = false.

  5. Anurag
    Anurag avatar
    3 posts
    Member since:
    Apr 2014

    Posted 04 Apr 2014 Link to this post

    Hi Princy,

    I have already tried the above mentioned solution but as we are using edit forms in a popup to edit the grid record this solution does not work . When the record is updated in the edit form popup it does not get saved and also new records are also not inserted. And also the grid is rebinded after any event with databindreason postbackviewstatenotpersisted.

  6. Viktor Tachev
    Viktor Tachev avatar
    2499 posts

    Posted 07 Apr 2014 Link to this post

    Hi Anurag,

    RadGrid is designed so that it needs to call it's Rebind() method when the commands listed in this article are fired. If the grid performance is slow try implementing the approaches listed in the performance optimization article suggested by Princy.

    Additionally you could try using custom paging in RadGrid so that only data for the items on the current page is retrieved from the database. There is also an online demo that illustrates custom paging for RadGrid.

    Alternatively you might also consider using Batch editing for RadGrid. This editing mode allows the user to make multiple changes and then submit them with a single request to the server.

    Viktor Tachev

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  7. Kate
    Kate avatar
    7 posts
    Member since:
    Jul 2014

    Posted 29 Jul 2014 in reply to Viktor Tachev Link to this post

    I have the exact same concern as Anurag. Why should it be necessary to rebind the grid if you click cancel.. or just clicking edit? I can see it rebinding on Update but not Edit and Cancel. The data is already there for those events.

    Is there any way to manually suppress this call to rebind on Edit or Cancel?

    I have a dynamic datatable built from disparate queries so it's really tough to implement other suggestions as I have to pull it all back and build the DataTable which I then bind to the grid. I just want to suppress all these unnecessary rebinds and only rebind if a record is Updated.
  8. Pavlina
    Pavlina avatar
    6187 posts

    Posted 01 Aug 2014 Link to this post

    Hello Kate,

    As my colleague Viktor already pointed RadGrid is designed so that it needs to call it's Rebind() method when the commands listed in Commands that invoke Rebind() implicitly article are fired.

    Regarding Edit and Cancel commands it is also necessary to rebind the grid when they fired. Note that all the commands that change the grid structure need rebind. When you click Edit the grid should create the editors and when Cancel is clicked they should be removed, otherwise the editors will not open and respectively will not close on Cancel. 


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  9. Kate
    Kate avatar
    7 posts
    Member since:
    Jul 2014

    Posted 01 Aug 2014 in reply to Pavlina Link to this post

    Hi Pavlina,
    I don't see the need to rebind on Edit and Cancel. Update, yes. But on edit the grid is just reading the values and putting them in textboxes and on cancel nothing is changing.

    It's kind of a moot point I guess since that's the way the control works whether it makes sense or not :) I have put a workaround in place for large data sets.

  10. Albert Shenker
    Albert Shenker avatar
    588 posts
    Member since:
    Mar 2004

    Posted 26 Mar 2015 Link to this post

    When Edit/Cancel are clicked, the grid structure is changed (to show/hide edit fields, forms, etc.). Hence the need to rebind.
  11. Amit
    Amit avatar
    9 posts
    Member since:
    Dec 2013

    Posted 19 Aug 2015 Link to this post

    Is there any update on this issue ? I am having similar issue where radgrid loses all selected items when a pop up control opens through edit form settings. 

     Any help would be appreciated. 



  12. Viktor Tachev
    Viktor Tachev avatar
    2499 posts

    Posted 24 Aug 2015 Link to this post

    Hello Amit,

    The RadGrid control needs to initiate postback when the Edit/Insert form is created. Thus, the control is also rebound. This is the default behavior with server-side binding.

    If you would like to persist the selected items in RadGrid after postback you should use the approach described in the article below:

    Viktor Tachev
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  13. Carl
    Carl avatar
    4 posts
    Member since:
    Sep 2014

    Posted 06 Sep 2017 Link to this post

    We are having a similar issue.  We have a template column in the grid with a button that opens a bootstrap modal.  The grid is ajaxified.  When the template column button is clicked it reloads the grid.  This causes latency on loading data in the modal.

    As the button is in an ajaxified grid I get what its doing, but how can we exclude a control inside the grid from this?


  14. Eyup
    Eyup avatar
    4073 posts

    Posted 12 Sep 2017 Link to this post

    Hi Carl,

    You can achieve this requirement using one of the approaches suggested in this article:

    I hope this will prove helpful.

    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  15. M
    M avatar
    1 posts
    Member since:
    Sep 2017

    Posted 15 Sep 2017 Link to this post

    Rebinding the grid on commands such as Edit may be fine (and understandable), however the telerik implementation has the following logical flaw.

    In a real world scenario where multiple users/processes may be creating/deleting records, the rebind can cause the grid's editindexes to become meaningless and potentially cause the wrong griditem to be edited.

    In the case where User A visits the page with the grid, then User B creates a new record but then User A clicks "edit" - the wrong item goes into edit-mode.


Back to Top