This is a migrated thread and some comments may be shown as answers.

RadGrid Rebind not Updating DataSource

5 Answers 787 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lukas
Top achievements
Rank 1
Lukas asked on 03 May 2013, 07:23 AM
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

5 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 03 May 2013, 08:17 AM
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
0
Princy
Top achievements
Rank 2
answered on 03 May 2013, 08:19 AM
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.

0
Lukas
Top achievements
Rank 1
answered on 03 May 2013, 08:26 AM
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?
0
Lukas
Top achievements
Rank 1
answered on 03 May 2013, 08:31 AM
thanks for your post with the radajaxmanager ;) it works fine now
0
pilar
Top achievements
Rank 1
answered on 17 May 2019, 09:25 PM
Thank youuu!!!!
Tags
Grid
Asked by
Lukas
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Lukas
Top achievements
Rank 1
pilar
Top achievements
Rank 1
Share this question
or