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
275
Get Ultragrid cell values while ultragrid is currently grouped by its column
posted

Hi, I have this Ultragrid that can be group by column. In my code I have to loop through its rows to get/set a specific cell value. My code goes like this:

 

foreach(var item in MyGrid.Rows)

{

    if((bool)item.Cells["Check"].Value)

    {

       item.Cells["ItemToBeFilledIn"].Value = MyTextBox.Text;

    }

}

 

Everything goes well if it is not grouped. But when I drag a column and group it by itself, there will be an exception message. When I try to debug, I saw that item.Cells is NULL.. Why? How can I get values from that cell?

  • 275
    Verified Answer
    posted

    Ok, now I get it. Here's the code I used:

     

    var allRowsEnumerator = MyGrid.Rows.GetRowEnumerator(GridRowType.DataRow, null, null);

                              

    foreach (UltraGridRow childRow in allRowsEnumerator)

    {

      if((bool)childRow.Cells["Check"].Value)

    {

        childRow.Cells["ItemToBeFilledIn"].Value = MyTextBox.Text;

    }

     }

     

    That's what I did. But I'm still open for any other suggestion