int.Parse(TxtId.Text);
This line is probably throwing an error.
If you try and parse a non-integer value into an integer, you will get an error.
To avoid these erros, try and use
Int.TryParse
[
^].
This can confirm if the value is an integer before parsing it into an integer variable.