protected void gvDetails_RowCommand1(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("AddNew"))
{
// TextBox txtsno = (TextBox)gvDetails.FooterRow.FindControl("txtsno");
TextBox txtchitti = (TextBox)gvDetails.FooterRow.FindControl("txtchitti");
con.Open();
SqlCommand cmd = new SqlCommand("insert into chitti(Chitti) values(" + txtchitti.Text + ")", con);
int result = cmd.ExecuteNonQuery();
con.Close();
if (result == 1)
{
BindMasteritemDetails();
lblresult.Text = txtchitti.Text + " Details inserted successfully";
}
else
{
lblresult.Text = txtchitti.Text + " Details not inserted";
}
}
}
i want to do only one time insertation of data , but this code inserting every time.i used
SqlCommand cmd = new SqlCommand("insert into chitti(Chitti) values(" + txtchitti.Text + " where SerialNo<2)", con); but it is not working..