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

Databoundgrid has too many columns

I''m using a Databoundgrid. I want to change the datasource dynamically depending on the user''s selection. When the grid first appears, it looks fine for the dataset that I''ve assigned to it. However, when I change the dataset to a different one, the first dataset''s columns remain in the grid and a new set of columns are added to the right side of the original columns. I want the original columns to be removed and replaced with ones that correspond to the second dataset''s fields. How do I do this?

2 Replies

AD Administrator Syncfusion Team August 27, 2004 06:24 PM UTC

A couple of things to try. You can try calling grid.Binder.InitializeColumns after resetting your datasource. You could set the grid''s datasource to null, change your dataset, and then reset the datasource. grid.BeginUpdate(); grid.DataSource = null; grid.DataSource = myNewDataTable; grid.EndUpdate(); grid.Refresh();


AD Administrator Syncfusion Team August 28, 2004 02:55 PM UTC

Thanks for the reply Clay. It turns out that my datasource was incorrect. The grid works fine now. Mike >A couple of things to try. > > >You can try calling grid.Binder.InitializeColumns after resetting your datasource. > >You could set the grid''s datasource to null, change your dataset, and then reset the datasource. > >grid.BeginUpdate(); >grid.DataSource = null; > grid.DataSource = myNewDataTable; >grid.EndUpdate(); >grid.Refresh(); >

Loader.
Live Chat Icon For mobile
Up arrow icon