Quote:
Conversion failed when converting the varchar value 'System.Web.UI.WebControls.TextBox' to data type int.
So, from the Exception, it is clear that you need to parse
TextBox
Text first something like below.
int temp = -1;
if (int.TryParse(textbox1.Text, out temp))
{
}
else
{
Throw new Exception("Invalid value entered.");
}