Hi,
I use the following code to retrieve the cell value when the groupbybox is hidden( the GroupBy is fixed)
dValue =
Double.Parse(Gridview2.Rows[0].Cells["Column2"].Value.ToString());
My question is, if I turn on the groupbox and allow the user to change the GroupBy columns, how can i retrieve this value ?
Here's the sample of my grid
(- )Column 1 :
Column2 Column3
10000 15
2000 16
How do I make sure I always get this value no matter how the column is grouped?
ThanksJoe
Hi Joe,
Okay, that's even easier (and makes more sense). :)
foreach (UltraGridRow row in this.ultraGrid1.Rows.GetAllNonGroupByRows()) { Debug.WriteLine(row.Cells["Column2"].Text); Debug.WriteLine(row.Cells["Column2"].Value); }
If you are allowing filtering in the grid, then you may want to use GetFilteredInNonGroupByRows instead of GetAllNonGroupByRows.
I actually want all the values in that column. What would be the syntax for it?
It depends on what value you want. Your code here is always referencing row 0.
But, as I'm sure you probably noticed, once you group the rows, row 0 will become a GroupByRow that doesn't have any cells.
So you need to walk down the chain and get to the real data row. But which one do you want?
The first row in the first group?
It's pretty unusual to need to target a specific row like that via the row index. Row 0 is unlikely to be anything special compared to other rows in the grid.
If that's what you want, though - to get the first data row, then you would have to get row 0, check the IsGroupByRow property. If it is one, then you have to cast it to a GroupByRow and access it's Rows property to get it's child rows. The child row could also be a GroupByRow, though - since you can have multiple levels of grouping. So you have to keep repeating that process until you find a row that is not a GroupByRow.