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 = iSortIndicatoroColumn.IsGroupByColumn = True
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."
Stack trace:
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()
Inner exception:
"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:
UltraWebGrid1.ResetBands()
UltraWebGrid1.ResetColumns()
UltraWebGrid1.ResetRows()
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.
THANKS!
That did the trick ;)