Question: I am attempting to take the `id` of each row of the datagrid `dgGrid` that has a checkbox selected and place it into an array `ruleids`. I've looked up examples online and noticed that this loop comes up. 

when I attempted to reconstruct the logic I get this error:

> 
> System.Web.UI.WebControls does not contain a definition for Rows.
> 
> 
> 

```
  int[] ruleids = null;
  foreach (GridViewRow  gvr in dgGrid.Rows)
  {
       if (((CheckBox)gvr.findcontrol("chkSelect")).Checked == true)
       {
            ruleids.add(gvr.cells["id"]);
       }
  }

```

Answer: 
Datagrid does not contain a definition for "rows". Instead of rows, it has "items".

So try with Datagrid.items...

```
    foreach (GridViewItem  gvr in dgGrid.Items)
{

    //BLA BLA BLA...
}

```

Hope this helps you...
```
foreach (DataGridItem dgi in DataGrid1.Items)
{
   tb.text = dgi.Cells[0].Text;
}

```

I Use this to loop DataGrid I hope to help you.