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

Cannot unregister UpdatePanel in Radgrid

1 Answer 74 Views
Grid
This is a migrated thread and some comments may be shown as answers.
RB
Top achievements
Rank 1
RB asked on 21 Apr 2014, 03:18 PM
I am creating a RadGrid as follows:
protected override void OnInit(EventArgs e)
      {
          this.Controls.Clear();
          this._RadLoadingPanel.ID = "_RadLoadingPanel";
          this._RadLoadingPanel.Transparency = 30;
          this._RadLoadingPanel.Skin = "WebBlue";
          this._RadLoadingPanel.BackgroundPosition = AjaxLoadingPanelBackgroundPosition.Center;
          this.Controls.Add(this._RadLoadingPanel);
  
          this._RadGrid1.Skin = "WebBlue";
          this._RadGrid1.Width = Unit.Percentage(98);
          this._RadGrid1.GridLines = GridLines.None;
  
          this._RadGrid1.AutoGenerateColumns = false;
          this._RadGrid1.AllowSorting = true;
          this._RadGrid1.GridLines = GridLines.None;
          this._RadGrid1.PageSize = 100;
          this._RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
          this._RadGrid1.ShowGroupPanel = true;
          this._RadGrid1.AllowPaging = true;
          this._RadGrid1.AllowSorting = true;        
          this._RadGrid1.EnableLinqExpressions = false;
          this._RadGrid1.MasterTableView.NoMasterRecordsText = string.Format("There are no documents associated with this order / quote / proposal.");
          this._RadGrid1.MasterTableView.Width = Unit.Percentage(100);                
            
          this._RadGrid1.NeedDataSource += RadGrid1_NeedDataSource;
                       
         // Setup Columns         
          GridBoundColumn boundColumn = new GridBoundColumn();
          this._RadGrid1.MasterTableView.Columns.Add(boundColumn);
          boundColumn.DataField = this._DocList.DescriptionColumn.ColumnName;
          boundColumn.HeaderText = "Document Type";
          boundColumn.UniqueName = "DocumentType";
          boundColumn.AllowSorting = true;    
         
          this._UpdatePanel.Unload += new EventHandler(UpdatePanel_Unload);
          this._UpdatePanel.ID = "ajaxPanel";
          this._UpdatePanel.UpdateMode = UpdatePanelUpdateMode.Always;
          this._UpdatePanel.ContentTemplateContainer.Controls.Add(this._RadGrid1);
  
          this.Controls.Add(this._UpdatePanel);
                        
          base.OnInit(e);
         
      }
protected override void OnPreRender(EventArgs e)
      {
          _RadGrid1.MasterTableView.Rebind();
          base.OnPreRender(e);      
          var ajaxManager = RadAjaxManager.GetCurrent(Page);
  
          if (ajaxManager != null)
              ajaxManager.AjaxSettings.AddAjaxSetting(this._UpdatePanel, this._RadGrid1, this._RadLoadingPanel);        
      }
It gives the following error:
Cannot unregister UpdatePanel with ID 'ajaxPanel' since it was not registered with the ScriptManager. This might occur if the UpdatePanel was removed from the control tree and later added again, which is not supported.
Parameter name: updatePanel

After reading in forums I added the following:
void UpdatePanel_Unload(object sender, EventArgs e)
     {
         MethodInfo methodInfo = typeof(ScriptManager).GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)
     .Where(i => i.Name.Equals("System.Web.UI.IScriptManagerInternal.RegisterUpdatePanel")).First();
         methodInfo.Invoke(ScriptManager.GetCurrent(Page),
             new object[] { sender as UpdatePanel });
     }

This did not resolve it. I even added Controls.clear, but did not work. When I comment out the  boundColumn.DataField = this._DocList.DescriptionColumn.ColumnName; statement, it displays a grid.
Please help me resolve this.
I forgot to mention that the Update {anel of this Radgrid is placed inside another Update Panel.

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 24 Apr 2014, 05:56 AM
Hi Ruchi,

I have already replied to your query in the following forum thread:
http://www.telerik.com/forums/cannot-unregister-updatepanel-in-radgrid

I suggest that we continue our discussion on the mentioned thread.

Regards,
Eyup
Telerik
 

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.

 
Tags
Grid
Asked by
RB
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or