Set the DataKeyField in GridView as
<asp:gridview id="gvList" runat="server" datakeynames="Id" xmlns:asp="#unknown">
...........
</asp:gridview>
Then you can get the key value for each column as:
for (int i = 0; i < gvList.Rows.Count; i++)
{
Int32 key = Convert.ToInt32(gvList.DataKeys[i].Value.ToString());
}
Or, if you are working between any cell-event you can use the object of DataGridViewCellEventArgs as
Int32 key = Convert.ToInt32(gvList.DataKeys[e.RowIndex].Value);