Convert
should not be your preferred way of getting an integer value from a user-input string.
User inputs should ba validated at all times. THe best way for that is to use the
TryParse
method. This way:
int adID;
if (!int.TryParse(txtSearchRegNo.Text, out adID) {
throw new ArgumentException("Entered text is not a valid integer representation.");
}
Hope this helps.