I have the codes up but when I try to update, it did not change anything. I am not sure where the problem went wrong
I have tried to change the index of email and others from 0-6 but when I use these index, everytime i tries to update, the email became UserID and so on.
Back End: protected void gvAccount_RowUpdating(object sender, GridViewUpdateEventArgs e) {
GridViewRow row = (GridViewRow)gvAccount.Rows[e.RowIndex];
string UserID = gvAccount.DataKeys[e.RowIndex].Values["UserID"].ToString();
string Email = ((TextBox)row.Cells[1].Controls[0]).Text;
string FirstName = ((TextBox)row.Cells[2].Controls[0]).Text;
string LastName = ((TextBox)row.Cells[3].Controls[0]).Text;
string Password = ((TextBox)row.Cells[4].Controls[0]).Text;
string Point = ((TextBox)row.Cells[5].Controls[0]).Text;
string Role = ((TextBox)row.Cells[6].Controls[0]).Text;
SqlCommand cmd = new SqlCommand("UPDATE UserRegister set Email = '" + Email + "', FirstName = '" + FirstName + "', LastName = '" + LastName + "', Password = '" + Password + "',Point = '" + Point + "',Role = '" + Role + "' WHERE UserID =" + UserID, con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
gvAccount.EditIndex = -1;
FillGrid();
}
There is no error message, but it just did not update anything. I am not sure if is the WHERE UserID = UserID problem. UserID is my primary key