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.
Hello,
Is there a way to bound a dataset into a GridControl ? (We need to use GridControl and can not GridDataBoundGrid Control due to the fact that we need cell style and row style features)
Thanks in advance,
Lea
ADAdministrator Syncfusion Team May 26, 2005 07:50 AM UTC
There are a couple ways t do this.
One is to move the data from the Datatable into the grid. You can use grid.PopulateValues to do this.
//dt is a datatable
this.gridControl1.BeginUpdate();
int nCols = dt.Columns.Count;
int nRows = dt.Rows.Count;
this.gridControl1.ColCount = nCols;
this.gridControl1.RowCount = nRows;
this.gridControl1.PopulateValues(GridRangeInfo.Cells(1, 1, nRows, nCols), dt);
this.gridControl1.EndUpdate();
this.gridControl1.Refresh();
If you want to save things only at the end, then you can handle the SaveCellInfo event and store a ''changed flag'' in the grid[e.RowIndex, 0].Tag to indicate a row has been changed. And then whne you are ready to save the changes, you can loop through the rows looking at these Tags to move the changes back to the DataTable.
If you want to change the DataTable dynamically as he changes take place in teh grid, you can do that directly in SaveCellInfo. (But do not set e.handled = true as you still want the grid to update in cell style cache.)
If you do not want to call PopulateValues to actually move the values from theh DataTable to the grid, you can also handle the QueryCellInfo event, and dynamically set e.Style.CellValue from the DataTable based on the e.RoeIndex and e.ColIndex passed it.