How to do databind to a texbox without assigning it a value?

0

I have a txtEmail textbox in a Display () method where I give you an email (through a query) and then display it in a user's profile (all ok).

txtEmail.Text = item["email"].ToString();//devolve sapo.pt

But when I try to edit the value through the query, if I try to edit it always writes the value that I had previously defined. Any tips?

SqlCommand cmd = new SqlCommand("UPDATE Utilizadores SET NomePessoal=@NomePessoal, nifPessoal=@nifPessoal, contacto=@contacto, email=@email WHERE (idLogin = @idLogin)", con);
        cmd.Parameters.AddWithValue("@email", txtEmail.Text); // escrevo hotmail.com, mas fica na mesma com o valor sapo.pt

I do the binding as well

//Seleção do perfil 
        if (dt.Rows.Count > 0)
        {
            foreach (DataRow item in dt.Rows)
            {
                txtid.Text = item["idLogin"].ToString();
                txtNP.Text = item["NomePessoal"].ToString();
                txtUT.Text = item["Utilizador"].ToString();
                txtNif.Text = item["nifPessoal"].ToString();
                txtCon.Text = item["contacto"].ToString();
                txtTipo.Text = item["tipo"].ToString();
            }
        }
        else
    
asked by anonymous 23.08.2018 / 18:25

0 answers