0

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);
        }
    }
2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by umamahesh2020
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.