The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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();
}
ADAdministrator 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
RFRasmus FynboMay 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 :)