Start by using the debugger: put a breakpoint on the line:
objPerson.PersonId= Convert.ToInt32(dgvPerson.DataKeys[gr.RowIndex].Values["PersonId"]);
And when the application stops, start looking at the parts of it to find out exactly what indexes etc. you are dealing with.
There are two obvious candidates:
dgvPerson.DataKeys[gr.RowIndex]
And
Values["PersonId"]
But without your code running, we can't tell which is responsible - so it's over to you!
When you know which is causing the problem, it shouldn't be a major problem for you to work out why it's not valid - but that probably requires both the rest of your code, and your sample data, neither of which we have access to.