inew = Convert.ToInt32(e.FormattedValue);
gives error because
you have handle this condition e.FormattedValue but not this,
e.FormattedValue that contains alphabet or special character (except +-.)
which can not be convert in to Int32
so,
check e.FormattedValue before converting in to int32
like this
if (e.FormattedValue.Trim() != "")
{
if IsNumeric(e.FormattedValue.Trim())
{
iold = oldValue;
inew = Convert.ToInt32(e.FormattedValue.Trim());
}
}
public static Boolean IsNumeric(string stringToTest)
{
int result;
return int.TryParse(stringToTest, out result);
}
Happy Coding!
:)