We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

DataBoundGrid - How to add column at runtime ?

I have a DataBound grid with dynamically created columns.
I need to add a column at runtime, but it does not appear.
Could you please advise?
Thanks.

Here is my code:
GridBoundColumn newCol = GridConfigurationHelper.createColumn();
GridHierarchyLevel hl = _grid.Binder.GetHierarchyLevel(0);
hl.GridBoundColumns.Add(newCol);

_grid.Binder.InitializeColumns();
_grid.Model.ColWidths.ResizeToFit(GridRangeInfo.Table(), GridResizeToFitOptions.IncludeHeaders);



3 Replies

HA haneefm Syncfusion Team January 9, 2008 03:57 PM UTC

Hi Gen,

Please try this code snippet and let me know if this helps.

GridBoundColumn newCol = GridConfigurationHelper.createColumn();
GridHierarchyLevel hl = _grid.Binder.GetHierarchyLevel(0);
hl.InternalColumns.Add(newCol);
GridBoundColumnsCollection columns = hl.InternalColumns.Clone() as GridBoundColumnsCollection;
_grid.GridBoundColumns = columns;

Best regards,
Haneef



GE Gen January 11, 2008 04:15 PM UTC


Thank you,
the problem is solved!

>Hi Gen,

Please try this code snippet and let me know if this helps.

GridBoundColumn newCol = GridConfigurationHelper.createColumn();
GridHierarchyLevel hl = _grid.Binder.GetHierarchyLevel(0);
hl.InternalColumns.Add(newCol);
GridBoundColumnsCollection columns = hl.InternalColumns.Clone() as GridBoundColumnsCollection;
_grid.GridBoundColumns = columns;

Best regards,
Haneef





JJ Jisha Joy Syncfusion Team January 12, 2008 04:52 AM UTC

Hi Gen,

Thank you for your update.

Regards,
Jisha



Loader.
Live Chat Icon For mobile
Up arrow icon