what is wrong with the code here... i am trying to update the values fetched in a row of a grid view by an edit,update,cancel command field button.
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
Label lblid = (Label)GridView1.Rows[e.RowIndex].FindControl("Elblid");
TextBox txtuser = (TextBox)GridView1.Rows[e.RowIndex].FindControl("EtxtUserName");
TextBox txtpass = (TextBox)GridView1.Rows[e.RowIndex].FindControl("EPassword");
if (lblid.Text != "" || lblid.Text != null)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["con"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("Update Login set UserName='" + txtuser.Text + "',Password='" + txtpass.Text + "' Where Id=" + lblid.Text, con);
cmd.ExecuteNonQuery();
con.Close();
GridView1.EditIndex = -1;
FillGrid();
}
This was the error thrown :
PS: when is set the event validation to be false in the page directives. this error disappeared but the code did nothing it was intended to.