when ultragrid1.rows(0).IsGroupByRow = True then i get the error Cannot set Column 'XYZ' to be null. Please use DBNull instead. for the below code. and when
ultragrid.rows(0).IsGroupByRow = false it deosnt give any error
Dim drow As DataRow = dt.NewRow()
For s = 0 To ultragrid1.Rows.Count - 1
For x = 0 To ultragrid1.DisplayLayout.Bands(ultragrid1.ActiveRow.Band.Index).Columns.Count - 1
drow(i) = IIf(IsDBNull(ultragrid1.Rows(s).GetCellValue(ultragrid1.DisplayLayout.Bands(ultragrid1.ActiveRow.Band.Index).Columns(x))) = True, _ DBNull.Value, _ ultragrid1.Rows(s).GetCellValue(ultragrid1.DisplayLayout.Bands(ultragrid1.ActiveRow.Band.Index).Columns(x)))
Nextdt.Rows.Add(drow)Next
Thanks in advance
Hello Mauryalsha,
I wanted to know if you were able to solve your issue based on these suggestions or you still need help. Please let me know.
Okay... so do you still need help with this?
DataTables do not support grouping, so it seems like maybe you will need to un-group the grid before you can copy the data. Either that or use the code I posted above to loop through all the data rows only.
hello,
I am tring to create a datatable with all the columns which are visible in the grid,since there are several calculated fields which are not present in my original datatable which is populated from my database.
Thanks
Hi,
I'm not sure I understand what you are asking. You cannot get a cell value from a GroupByRow, because GroupByRows don't have cells. When you group the grid, the root level rows of the grid become GroupByRows and the real data rows are arranged underneath those rows as child rows.
So you will need to change your loop to skip over the GroupByRow and only look at the data rows. How you do that depends on what you are trying to do. This code is very hard to read, and I'm a bit confused because it looks like you are adding rows to the grid's datasource inside a loop while iterating the rows of the grid. That doesn't make a lot of sense. Unless dt is some other DataTable not associated with the grid.
If you want to loop through just the data rows in the grid and skip the GroupByRows, then you could do this:
For Each row As UltraGridRow In Me.UltraGrid1.Rows.GetAllNonGroupByRowsNext