Clearing a DataBoundGrid

I''m using this code for rebinding datasets to the grid, but whenever the dataset is empty or null the grid doesn''t clear by it self. I would it expect to display nothing instead of the last known dataset. How do I get it to clear the grid when the dataset is empty? private void BindData(Syncfusion.Windows.Forms.Grid.GridDataBoundGrid grid, DataSet ds, bool isEmpty) { grid.BeginInit(); grid.SuspendLayout(); if (isEmpty == true) grid.DataSource = null; else grid.DataSource = ds != null ? ds.Tables[0] : null; grid.ResumeLayout(true); grid.EndInit(); }

2 Replies

AD Administrator Syncfusion Team May 2, 2006 03:57 AM UTC

Hi Rasmus, Please try this code to clear the Internal columns in GridDataBoundGrid .Here is a code snippet. private void BindData(Syncfusion.Windows.Forms.Grid.GridDataBoundGrid grid, DataSet ds, bool isEmpty) { grid.BeginInit(); grid.SuspendLayout(); gridDataBoundGrid1.Binder.InternalColumns.Clear(); //For clear the column in a grid if (isEmpty == true) grid.DataSource = null; else grid.DataSource = ds != null ? ds.Tables[0] : null; grid.ResumeLayout(true); grid.EndInit(); } Please let me know if this helps. Regards, Haneef


RF Rasmus Fynbo May 2, 2006 10:44 PM UTC

Ah, we figured out that the problem occured because in our datamodel we made a new dataset instead of filling new data into the same dataset. Changing that made everything else work, but thanks for the solution :)

Loader.
Up arrow icon