That means the
String
you are entering is not a valid
integer
.
You should go with
int.TryParse[
^].
This will not throw you exception. Rather it will try to parse the
String
, else it will not do anything.
So, do like...
int num = 0;
bool res = int.TryParse(txtid.Text, out num);
if (!res)
{
}