It is very simple.copy paste the code in your page load event
string sqlText = "SELECT MAX(product_id) FROM Product ";
SqlConnection con3 = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\QXScustomerportalDB.mdf;Integrated Security=True;User Instance=True");
SqlCommand command = new SqlCommand(sqlText, con3);
try
{
con3.Open();
string pcount = Convert.ToString( command.ExecuteScalar());
if (pcount.Length == 0)
{
TextBox1.Text = "1";
}
else
{
int pcount1 = Convert.ToInt32(pcount);
int pcountAdd = pcount1 + 1;
TextBox1.Text = pcountAdd.ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con3.Close();
}