Hello all.
I am new to .net development.
I am inserting the data and i want the data to get displayed in the grid view as i enter the data.But it doesn't get displayed immediately.
If i refresh the page,the data gets inserted twice.
I tried to solve this using (!IsPostBack) property though i get the same bug.
My code is here:
try
{
if (cn.State == ConnectionState.Closed)
{
cn.Open();
}
da.InsertCommand = new SqlCommand("insert into tbl_Comment values ('" + authenticate + "','" + txt_newitem.Text + "','" + txt_location.Text + "','" + date.ToString() + "','" + 1 + "')", cn);
da.InsertCommand.ExecuteNonQuery();
da.Update(ds);
GridView1.DataBind();
}
catch (SqlException ex)
{
lbl_error.Text = ex.Message;
}
finally
{
cn.Close();
}
Can any one guide me where i am making the mistake ?