In Your Second Case when You leave your Textboxfield (SrNo empty)
then it passes "" to the databse which is incompatible with your Decimal field
sr.No(Decimal(18,0)
So need to check before passing it to the database like below
Decimal Value1;
if(TextBox1.text=="")
{
Value1 = 0.0;
}
else
{
Value1 = Convert.ToDecimal(TextBox1.text);
}
string Value2= TextBox2.Text;
Con.Open();
Cmd = new SqlCommand("Insert into t1 values (@Value1,@Value2)", Con);
Cmd.Parameters.AddWithValue("@Value1", Value1);
Cmd.Parameters.AddWithValue("@Value2", Value2);
Cmd.ExecuteNonQuery();
Con.Close();