RadGrid Rebind not Updating DataSource

6 posts, 0 answers
  1. Lukas
    Lukas avatar
    3 posts
    Member since:
    May 2013

    Posted 03 May 2013 Link to this post

    Hi there,

    i want to update my DataSource of the RadGrid with the Rebind-Method in a Button_Click-Event. 
    In the NeedDataSource i update the DataSource properly but the new DataSource is not shown in my Grid. It just don´t do any update.

    Can you me help out here?

    Here my Grid:

    <telerik:RadGrid ID="radInvoiceOverview"
                                    runat="server"
                                    AutoGenerateColumns="true"
                                    OnNeedDataSource="radInvoiceOverview_NeedDataSource"
                                    GridLines="None"
                                    Width="650px"
                                    AllowPaging="true"
                                    PageSize="100"
                                    ShowHeader="true"
                                    ItemStyle-Height="30px"
                                    AlternatingItemStyle-Height="30px">
     
                       <ClientSettings AllowKeyboardNavigation="true"
                                       EnablePostBackOnRowClick="true"
                                       EnableRowHoverStyle="true">
     
                           <Selecting AllowRowSelect="true"/>
                       </ClientSettings>
     
                       <SortingSettings  EnableSkinSortStyles="false"/>
     
                       <PagerStyle  Mode="NumericPages"
                                    AlwaysVisible="true"
                                    PageButtonCount="10"
                                    PagerTextFormat="{4} Page {0} from {1}, Transactions {2} to {3}"/>
     
                       
                       <MasterTableView EnableNoRecordsTemplate="true" AutoGenerateColumns="true">
                           <NoRecordsTemplate>
                               <div style="width:100%;text-align:center;margin-top:10px;margin-bottom:10px;"><b>some Text</b></div>
                           </NoRecordsTemplate>
                       </MasterTableView>
                   </telerik:RadGrid>


    And here my Events:
    protected void btnShow_Click(object sender, EventArgs e)
            {
                radInvoiceOverview.Rebind();
            }
     
            protected void radInvoiceOverview_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
            {
                 
                try
                {
                    radInvoiceOverView.DataSource = GetUnprintedInvoicesForClient(); //<-- brings a DataTable as Source
                }
                catch (Exception ex)
                {
                    //do some logging
                }
            }
    Do you know what i´m missing in this scenario?

    regards
    Luke
  2. Jayesh Goyani
    Jayesh Goyani avatar
    2733 posts
    Member since:
    May 2010

    Posted 03 May 2013 Link to this post

    Hello,

    if you are using RadAjaxManager/radAjaxMaangerProxy

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
          <AjaxSettings>
              <telerik:AjaxSetting AjaxControlID="btnShow">
                  <UpdatedControls>
                      <telerik:AjaxUpdatedControl ControlID="radInvoiceOverview" LoadingPanelID="RadAjaxLoadingPanel1" />
                  </UpdatedControls>
              </telerik:AjaxSetting>
          </AjaxSettings>
      </telerik:RadAjaxManager>
      <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
      </telerik:RadAjaxLoadingPanel>

    Thanks,
    Jayesh Goyani
  3. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 03 May 2013 Link to this post

    Hi,

    The NeedDataSource event will fire for the first time and the Radgrid will get populated. In your code on button click, you are calling Rebind() method  which will again invoke NeedDataSource event and populate the RadGrid with the Same data... That is why the Radgrid data is not  changed. Please elaborate your scenario for more help.

    Thanks,
    Princy.

  4. Lukas
    Lukas avatar
    3 posts
    Member since:
    May 2013

    Posted 03 May 2013 Link to this post

    ah sry... i forgot to say that the first time the needDataSource returns another DataTable as when the Button_Click is fired....

    at the first time it´s just an empty DataTable and the other time it has serveral rows.... so actually the grid should be updated or do i missing something?
  5. Lukas
    Lukas avatar
    3 posts
    Member since:
    May 2013

    Posted 03 May 2013 Link to this post

    thanks for your post with the radajaxmanager ;) it works fine now
  6. pilar
    pilar avatar
    1 posts
    Member since:
    May 2019

    Posted 17 May in reply to Jayesh Goyani Link to this post

    Thank youuu!!!!
Back to Top