I mostly used this code snippet to validate textbox user input. But I think you can use it on a DataGridViewCell as well. Give it a try.
And you don't have to use ASCII codes in C#. You can compare
e.KeyChar to an integer which represents the ASCII value directly.
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != 8)
{
if (e.KeyChar < 48 | e.KeyChar > 57)
{
e.Handled = true;
}
}
}