Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1290
Problem with Grouping the second time
posted

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
oColumn.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."

Stack trace:

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.

Parents
  • 65
    Verified Answer
    posted

    You may need to reset the columns, rows and bands.  For example:

    UltraWebGrid1.ResetBands()

    UltraWebGrid1.ResetColumns()

    UltraWebGrid1.ResetRows()

     

     

     

Reply Children