try:for(int i=0;i<dg.Items.Tables.Count)
{
for(int j=0;j<dg.Items.Tables[i].Rows.Count)
{
...
}
}