Hi, I am having problems when setting group-by columns in code. Here is a small snippet from InitializeLayout event:
oColumn = uwgGrid.Columns.FromKey(sColumnKey)oColumn.SortIndicator = iSortIndicator
I take several columns from the grid, set their sorting (ascending/descending) and set their IsGroupByColumn property to true (this adds the column to SortedColumns collection).
It works fine the first time, the groups are displayed properly. But when I do the same procedure the second time (same resultset is returned from database, same code executes in InitializeLayput event, same colums are used for grouping) I am getting error:
"Failed to compare two elements in the array."
at System.Array.BinarySearch(Array array, Int32 index, Int32 length, Object value, IComparer comparer) at System.Collections.SortedList.IndexOfKey(Object key) at System.Collections.SortedList.get_Item(Object key) at Infragistics.WebUI.UltraWebGrid.UltraGridLayout.RegisterGroupByColumn(UltraGridColumn groupedColumn) at Infragistics.WebUI.UltraWebGrid.UltraWebGrid.GroupRows(RowsCollection rows, UltraGridColumn column) at Infragistics.WebUI.UltraWebGrid.UltraWebGrid.SortGroupRows(RowsCollection rows) at Infragistics.WebUI.UltraWebGrid.UltraWebGrid.PerformGroupRows() at Infragistics.WebUI.UltraWebGrid.DBBinding.BindList(IEnumerable datasource) at Infragistics.WebUI.UltraWebGrid.DBBinding.DataBind(Object dataSource, String dataMember) at Infragistics.WebUI.UltraWebGrid.UltraWebGrid.DataBind()
"Object reference not set to an instance of an object."
at Infragistics.WebUI.UltraWebGrid.UltraGridLayout.GroupByColumnComparer.Compare(Object x, Object y)at System.Array.BinarySearch(Array array, Int32 index, Int32 length, Object value, IComparer comparer)
I've tried to clear the grid completely before the second call, as well as clearing SortedColumns collection - it doesn't help. I am using NetAdvantage 2006 Vol. 3 CLR 2.0.
Any help is greatly appreciated.
You may need to reset the columns, rows and bands. For example:
That did the trick ;)
After uprading to 2009.1 for CLR2.0 (with hotfix 2013) the error started to happen again. So far I've been unsuccessful in solving it. Any help is appreciated.
I am experiencing the same issue, despite calling WebGrid.ResetBands(), WebGrid.ResetColumns() and WebGrid.ResetRows() before binding the WebGrid. Is there a fix for this issue yet?
I did not
encounter "Failed to compare two elements in the array." until I
started using ResetBands(), ResetColumns(), & ResetRows(). So I tried to
solve the grouping on rebind problem without them.
discovered that grouping occurs only when the value of IsGroupByColumn changes
from False to True. If it is already true before the DataBind() then no
grouping occurs when PerformGroupRows() is called a second time (bug?).
Thank you so much - I was having the same problem.
Setting all the IsGroupBys to false before rebinding, and then setting them to true again where appropriate stopped my crashing!
I am also getting the same error. Can anybody suggest a solution for this. I have done all the above suggested.
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Failed to compare two elements in the array.
This is the error i am getting while second time grouping.