Hello, I have the following strange problem: I have two ultragrid , one called "gr" and the other "theMultiSelectGrid". I start to databind the grid"gr" with an existing dataset, and then I iterate to make some changes.
If I put a messageBox after the first databingind, the operation works fine and the data gets modified during the iteration. But if I remove the MessageBox, the data do not get updated in the iteration.
What is going on?
gr.DataBind(ds);
// MessageBox.Show("XXX.");
for (int i = 0; i <= theMultiSelectGrid.Grid.Rows.Count - 1; i++)
{
UltraGridRow drA = theMultiSelectGrid.Grid.Rows[i];
string CoteA = drA.GetCellValue("Code").ToString();
string AnneeA = drA.GetCellValue("Cat2").ToString();
for (int j = 0; j <= gr.Grid.Rows.Count - 1; j++)
UltraGridRow drB = gr.Grid.Rows[j];
string CoteB = drB.GetCellValue("Code").ToString();
string AnneeB = drB.GetCellValue("Annee").ToString();
if (CoteA == CoteB && AnneeA == AnneeB)
//specific code
}
My best guess is that gr has no rows because it hasn't painted yet. Although, I would have thought that accessing the rows collection would have forced them to get created.
Try calling gr.Refresh to force a paint after you bind it and see if that helps.