I am implementing a RadGrid that lists admin information messages. Each row has a row delete X and I have a Remove All button. The single row deletes work fine but the Remove All gives after the delete.
[ArgumentOutOfRangeException: capacity was less than the current size.
Parameter name: value]
System.Collections.ArrayList.set_Capacity(Int32 value) +11392869
Telerik.Web.UI.GridTableView.GetEnumerator(Boolean useDataSource, GridEnumerableBase resolvedDataSource, ArrayList dataKeysArray, Boolean shouldClearDataKeys) +450
Telerik.Web.UI.GridTableView.GetJsonData(Int32 startRowIndex, Int32 maxRowsCount) +1013
Telerik.Web.UI.RadGrid.InitializeDesktopGridTableViewData(GridTableView tableView, Dictionary`2 data) +2181
Telerik.Web.UI.RadGrid.InitializeGridTableViewData(GridTableView tableView) +105
Telerik.Web.UI.RadGrid.InitializeGridTableViewsRecursive(GridTableView tableView) +95
Telerik.Web.UI.RadGrid.DescribeProperties(IScriptDescriptor descriptor) +4419
Telerik.Web.UI.RadGrid.DescribeComponent(IScriptDescriptor descriptor) +49
Telerik.Web.UI.RadCompositeDataBoundControl.Telerik.Web.IControl.DescribeComponent(IScriptDescriptor descriptor) +42
Telerik.Web.UI.ScriptRegistrar.GetScriptDescriptors(Control control) +210
Telerik.Web.UI.ScriptRegistrar.GetScriptDescriptors(WebControl control) +36
Telerik.Web.UI.RadCompositeDataBoundControl.GetScriptDescriptors() +35
Telerik.Web.UI.RadCompositeDataBoundControl.System.Web.UI.IScriptControl.GetScriptDescriptors() +51
System.Web.UI.ScriptControlManager.RegisterScriptDescriptors(IScriptControl scriptControl) +490
System.Web.UI.ScriptManager.RegisterScriptDescriptors(IScriptControl scriptControl) +55
Telerik.Web.UI.RadCompositeDataBoundControl.RegisterScriptDescriptors() +83
Telerik.Web.UI.RadCompositeDataBoundControl.RenderContents(HtmlTextWriter writer) +67
Telerik.Web.UI.RadGrid.RenderContents(HtmlTextWriter writer) +102
Telerik.Web.UI.GridBaseDataList.Render(HtmlTextWriter writer) +132
Telerik.Web.UI.RadGrid.Render(HtmlTextWriter writer) +217
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +66 ... lots more ...
I am creating my grid completely from C# code with a very minimal grid definition in the . The remove all looks like this.
protected void RemoveAll_Click(object sender, EventArgs e)
{
HomeGrid.DataSource = null;
DataService.Factory().RemoveAllMessages(user.orgId);
HomeGrid.Rebind();
}
This is my grid definition without the columns
RadGrid adminGrid = HomeGrid;
adminGrid.NeedDataSource += new GridNeedDataSourceEventHandler(AdminGrid_NeedDataSource);
adminGrid.Skin = "Default";
adminGrid.AutoGenerateColumns = false;
adminGrid.EnableViewState = false;
adminGrid.GroupingEnabled = false;
adminGrid.AllowPaging = true;
adminGrid.PageSize = 500;
adminGrid.Height = Unit.Percentage(100);
adminGrid.EnableHeaderContextMenu = true;
adminGrid.AllowSorting = true;
adminGrid.AllowFilteringByColumn = true;
adminGrid.AllowMultiRowSelection = false;
adminGrid.AllowAutomaticDeletes = true;
adminGrid.ClientSettings.EnableRowHoverStyle = true;
adminGrid.ClientSettings.Selecting.AllowRowSelect = true;
adminGrid.ClientSettings.Selecting.EnableDragToSelectRows = true;
adminGrid.ClientSettings.ReorderColumnsOnClient = true;
adminGrid.ClientSettings.AllowColumnsReorder = true;
adminGrid.ClientSettings.ColumnsReorderMethod = GridClientSettings.GridColumnsReorderMethod.Reorder;
adminGrid.ClientSettings.Virtualization.EnableVirtualization = true;
adminGrid.ClientSettings.Virtualization.InitiallyCachedItemsCount = 2000;
adminGrid.ClientSettings.Scrolling.AllowScroll = true;
adminGrid.ClientSettings.Scrolling.UseStaticHeaders = true;
adminGrid.ClientSettings.Scrolling.ScrollHeight = Unit.Percentage(100);
adminGrid.ClientSettings.Resizing.AllowColumnResize = true;
adminGrid.PagerStyle.Mode = GridPagerMode.NextPrevNumericAndAdvanced;
adminGrid.GroupingSettings.CaseSensitive = false;
and this my RadGrid definition
<
asp:panel
runat
=
"server"
ID
=
"HomeGridPanel"
CssClass
=
"windowPercent"
>
<
telerik:RadGrid
runat
=
"server"
ID
=
"HomeGrid"
OnItemCommand
=
"HomeGrid_ItemCommand"
></
telerik:RadGrid
>
</
asp:panel
>
I looked at other posts and could not figure out anything to do about this. I added AllowAutomaticDeletes based on searches which did not help.
How can I get rid of the ArrayList ArgumentOutOfRangeException when the Grid goes from having data to no data on a Rebind()?
On removing single rows going from 1 to zero works fine but Remove All gives the error one row. I think the difference is the single row remove is done from an OnItemCommand RadGrid call while the Remove All is done from a server button click method.
George