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
1175
Problem creating a datatable from selected rows in an ultragrid
posted
I use ultragrids column chooser to created a calculated column, then I let the user select certain rows, then I create a datatable from the ultragrid and save that data. But for some reason when I try to create the datatable it throws an error because of null values in the calculated column, even though I can see there is data in the rows it's saying are empty.Below is the code I'm using, the line with the arrow pointing to it should only be hit if there is no data in the cell, but I can see the data in the ultragrid and this line is still being hit.

Oh yeah to make it even stranger, when I highlight all the rows by hand the code works, when I use the right click highlight all is when it fails

I'm using Version 6.1 and upgrading is not an option at this current point in time.

for (int x = 0; x < ultraGridTemp.Selected.Rows.Count; x++)

{

DataRow drow = dt2.NewRow();for (int i = 0; i < ultraGridTemp.DisplayLayout.Bands[0].Columns.Count; i++)

{

if (ultraGridTemp.Selected.Rows[x].Cells[i].Value == null || ultraGridTemp.Selected.Rows[x].Cells[i].Value == System.DBNull.Value)

{

drow[i] = System.DBNull.Value;

}

else

{

drow[i] = ultraGridTemp.Selected.Rows[x].Cells[i].Value;

}

}

dt2.Rows.Add(drow);

}

Here is the code to highlight all the rows  this.ultraGrid1.BeginUpdate();for (int i = 0; i < this.ultraGrid1.Rows.Count; i++)

{

if (!this.ultraGrid1.Rows[i].IsFilteredOut)

{

this.ultraGrid1.Rows[i].Selected = true;

}

}

this.ultraGrid1.EndUpdate();

Parents Reply Children
No Data