I am creating a RadGrid as follows:
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:
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.
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);
}
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.