The easiest way is to use foreach :
foreach(GridViewRow row in GridView2.Rows) {
Edit: according to your changes, you are accessing the column incorrectly, you should start at 0:
foreach(GridViewRow row in GridView2.Rows) { for(int i = 0; i < GridView2.Columns.Count; i++) { String header = GridView2.Columns[i].HeaderText; String cellText = row.Cells[i].Text; } }
source share