我有这段代码从 SQL 获取返回查询并将其放在标签中。问题是,当我单击搜索按钮时,标签不会填充。但是当我进入调试模式时,它有值。这是为什么?!帮助!
//I've cut down the code here to make the question clearer
//But these 4 fields were all valid properties - Sayse
public string FirstName
public string MiddleName
public string LastName
public string Email
public void SearchAffectedUser()
{
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
using (SqlCommand com_retrieve = new SqlCommand("Reader.usp_SearchAffectedUser", con))
{
com_retrieve.CommandType = CommandType.StoredProcedure;
com_retrieve.Parameters.Add("@fld_EmployeeId", SqlDbType.Int).Value = AffectedUser;
con.Open();
com_retrieve.ExecuteNonQuery();
SqlDataReader dr = com_retrieve.ExecuteReader();
if (dr.Read())
{
FirstName = dr.GetValue(0).ToString();
MiddleName = dr.GetValue(1).ToString();
LastName = dr.GetValue(2).ToString();
Email = dr.GetValue(3).ToString();
}
}
}
}
protected void findAffectedUserButton_Click(object sender, EventArgs e)
{
ticket.AffectedUser = affectedUserTextBox.Text;
ticket.FirstName = firstNameValueLabel.Text;
ticket.MiddleName = middleNameValueLabel.Text;
ticket.LastName = lastNameValueLabel.Text;
ticket.Email = emailValueLabel.Text;
ticket.SearchAffectedUser();
}