I have one grid view with 4 columns(UserId,Description,Password,Change Password[Button]).
When i click on change password the panel with 3 textboxes(UserID,New Password,Confirm Password) and save button appears.
After changing password the panel disappears but the password in the gridview remains same as previous.
I want to update the password column.
Following is my Save Button Click
Code
protected void BindGridView()
{
try
{
DataTable dt = new DataTable();
dt = (DataTable)Session["userinfo"];
gvPassInfo.DataSource = dt;
gvPassInfo.DataBind();
}
catch (Exception ex)
{
//lblMessage.Text = DataObjects.Error_Message();
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
clsUser objuser = new clsUser();
string user = txtUserid.Text;
string NewPassword = txtNewPassword.Text;
string ConfirmPassword = txtConfirmNewPassword.Text;
objuser.UpdateSystemPassword(user, NewPassword);
Response.Write("<script LANGUAGE='JavaScript' >alert('Password Changed Successfully...'); document.location='" +ResolveClientUrl("~\\PasswordInformation_Details.aspx") + "'; </script>");
BindGridView();
panelChangePassword.Visible = false;
}
protected void btnSearch1_Click(object sender, EventArgs e)
{
try
{
using (MySqlConnection conn = new MySqlConnection(clsUser.connStr))
{
conn.Open();
string strQuery = "select DISTINCT user_id,description,sap_system_password from sap_password_info where user_id is not null";
if (txtSid.Text !="")
{
strQuery += " AND sid = '" + txtSid.Text + "'";
}
if (txtClient.Text != "")
{
strQuery += " AND client_no = '" + txtClient.Text + "'";
}
if (txtUser.Text != "")
{
strQuery += " AND user_id = '" + txtUser.Text + "'";
}
MySqlCommand cmd = new MySqlCommand(strQuery, conn);
DataTable dt = new DataTable();
dt.Load(cmd.ExecuteReader(CommandBehavior.CloseConnection));
Session["userinfo"] = dt;
Response.Redirect("~\\PasswordInformation_Details.aspx");
}
}
catch (Exception ex)
{
//lblMessage.Text = DataObjects.Error_Message();
lblMsg.Text = ex.Message.ToString();
}
}
The code is in C# and back end is MySQL DB Server.. please help..
Update the
GridViewat the end of your update event/save button click eventEdit
you are updating the record in the database but you are not fetching new data that’s the reason you are getting old information
so after following statement fetch the data from database and update the session dataset with new data then your problem will solve…
Write this code in old page
In New File