How can I retrieve the previous value of a DataGridView cell using the CellValueChanged event?

Hi members
i have a datagridview which i make (insert/update into db)
if the cell in datagridview is null its an insert simple but
if it has a value its an update( to make the update i want get that value in the cell and use it for the update after )
how i can retrieve that value ?
i use CellValueChanged event for validating
i have the idea to use :
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
newvalue = (int)dataGridView1[e.ColumnIndex, e.RowIndex].Value;
}
private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
{
oldvalue = (int)dataGridView1[e.ColumnIndex, e.RowIndex].Value;
}
but i have no idea how to store the old value in CellBeginEdit to use it in CellEndEdit after
please help
i need the old value for updating query because its the primary key in the database
so based at that value i can identify the row in the db and make my update to the new one
and i've already solved the problem i have no idea how to marked as answered?