it won't show any error but after clicking the update it show the previous data again

protected void gvdatatable_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {         
        try
        {
            GridViewRow row = (GridViewRow)gvdatatablle.Rows[e.RowIndex];
            Label lbl = (Label)row.FindControl("lblid");
            TextBox txt1 = (TextBox)row.FindControl("txtpassword");
            TextBox txt2 = (TextBox)row.FindControl("txtconpassword");
            TextBox txt3 = (TextBox)row.FindControl("txtemail");

            gvdatatablle.EditIndex = -1;
            SqlConnection con = new SqlConnection(constring);
            con.Open();


            cmd = new SqlCommand("update_record", con);

            cmd.Parameters.Add("@Id", SqlDbType.VarChar).Value = lbl.Text;
            cmd.Parameters.Add("@Password", SqlDbType.VarChar).Value = txt1.Text;
            cmd.Parameters.Add("@ConfirmPassword", SqlDbType.VarChar).Value = txt2.Text;
            cmd.Parameters.Add("@EmailId", SqlDbType.VarChar).Value = txt3.Text;

            cmd.CommandType = CommandType.StoredProcedure;
            //SqlCommand cmd = new SqlCommand("update  Login set Password='" + txt1.Text + "' , ConfirmPassword='" + txt2.Text + "',EmailId='" + txt3.Text + "' where Id='" + lbl.Text + "'", con);

            cmd.ExecuteNonQuery();
            con.Close();

            bind();
            
           
        }
        catch (Exception ex)
        {
            System.Windows.Forms.MessageBox.Show(ex.Message);
        }
    }

try gvdatatable.DataBind() after executing the Update statement.

I put that one also but it won't works.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.