Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
695
error when ultragrid.rows(0).IsGroupByRow = True
posted

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)))

Next
dt.Rows.Add(drow)
Next

Thanks in advance

Parents
  • 469350
    Offline posted

    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.GetAllNonGroupByRows

    Next

Reply Children