Hi, you are binding the values to the textbox in the pageload. but you are not checking the ispostback the changes to be done in your code is marked in red color
protected void Page_Load(object sender, EventArgs e)
{
string EmpID = (string)Request.QueryString["empid"];
if (!Page.IsPostBack)
{
txtEmpName.ReadOnly = true;
txtMySiteURL.ReadOnly = true;
txtRO.ReadOnly = true;
txtEMail.ReadOnly = true;
FileUpload1.Enabled = false;
btnUpdate2.Enabled = false; SetValue(EmpID);
}
}
private void SetValue(string EmpID)
{
//EmpID = (string)Request.QueryString["empid"];
string constr = ConfigurationManager.ConnectionStrings["ConStr"].ToString();
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand cmd = new SqlCommand("Usp_SetEmpById", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@empid", Convert.ToInt32(EmpID));
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
txtEmpName.Text = sdr["EmpName"].ToString();
txtMySiteURL.Text = sdr["MySiteURL"].ToString();
txtRO.Text = sdr["ReportingOfficer"].ToString();
txtEMail.Text = sdr["EMail"].ToString();
}
con.Close();
}
|