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.
In code below, I attempt to attach a DataTable to a GDBG. This grid is then used by the ExcelRW to create a worksheet. After this code runs, grid.Model.RowCount returns 0 despite the fact that there are 11 rows (grid.Model.ColCount) properly returns 2 because there are two columns. Where are my rows? They are in the datatable...
GridDataBoundGrid grid = new GridDataBoundGrid() ;
grid.BeginInit() ; //had to do in order for the Binder to be defined???
grid.EndInit() ;
GridBoundColumn gbc = new GridBoundColumn() ;
gbc.MappingName = "Name" ;
gbc.HeaderText = "" ;
grid.Binder.GridBoundColumns.Add(gbc) ;
gbc = new GridBoundColumn() ;
gbc.MappingName = "Value" ;
gbc.HeaderText = "" ;
grid.Binder.GridBoundColumns.Add(gbc) ;
grid.DataBoundGridModel.BeginUpdate() ;
grid.Binder.SuspendBinding() ;
grid.Binder.DataSource = dt ; //contains 11 rows - confirmed
grid.Binder.ResumeBinding() ;
grid.DataBoundGridModel.EndUpdate() ;
This apparently affects the ColWidths collection as well?? Is this because the grid is never actually drawn?
ADAdministrator Syncfusion Team March 29, 2005 09:35 AM UTC
Yes. The colwidths sizings are not set until the grid is displayed.
Likely calling grid.Refresh after the code you listed will make grid.Model.RowCount reflect the proper value, but it may not set the colwidths. If not, you can try explicitly calling:
grid.AllowResizeToFit = false;
grid.Model.ColWidths.ResizeToFit(GridrangeInfo.Table(), GridResizeToFitOptions.IncludeHeaders);