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
1220
here we go.. dynamic columns :)
posted

ok..

i am 99% successful in creating a grid with columns added dynamically from database. the reason for this is so that when our data feeds get extended, we don't have to deploy code with column definitions etc, we can just add some metadata in a table and it appears in our grids.

 

the problem is as follows. i can re-create the columns on INIT. but  sometimes, i need the grid to use viewstate, and so, after INIT the columns get re-created from postback and i need to override them again from database.

in order to avoid adding the columns twice, i call this.Columns.Clear() before re-adding them.

if the grid is in OutlookGroupBy mode, i get the exception below. this leads me to beleive that this.columns.Clear() does not wipe all the information completely. something is still there and blows up with null exception. again this happens on 2nd postback with outlookGroupBy layout enabled.

exception:

[NullReferenceException: Object reference not set to an instance of an object.]
Infragistics.WebUI.UltraWebGrid.GroupByColumnComparer.Compare(Object x, Object y) +165
System.Array.BinarySearch(Array array, Int32 index, Int32 length, Object value, IComparer comparer) +229

[InvalidOperationException: Failed to compare two elements in the array.]
System.Array.BinarySearch(Array array, Int32 index, Int32 length, Object value, IComparer comparer) +289
System.Collections.SortedList.IndexOfKey(Object key) +31
System.Collections.SortedList.get_Item(Object key) +15
Infragistics.WebUI.UltraWebGrid.UltraGridLayout.RegisterGroupByColumn(UltraGridColumn groupedColumn) +26
Infragistics.WebUI.UltraWebGrid.UltraWebGrid.GroupRows(RowsCollection rows, UltraGridColumn column) +321
Infragistics.WebUI.UltraWebGrid.UltraWebGrid.SortGroupRows(RowsCollection rows) +314
Infragistics.WebUI.UltraWebGrid.UltraWebGrid.PerformGroupRows() +186
Infragistics.WebUI.UltraWebGrid.DBBinding.BindList(IEnumerable datasource) +1275
Infragistics.WebUI.UltraWebGrid.DBBinding.DataBind(Object dataSource, String dataMember) +860
Infragistics.WebUI.UltraWebGrid.UltraWebGrid.DataBind() +405