I am a little stumped at the moment. i have two label controls on my web app that am trying to assign some text values to, the first label works just fine while the second doesn't. the controls are both referenced during the masterpage Load event, see code below
protected void Page_Load(object sender, EventArgs e)
{
string id = Convert.ToString(Session["id"]);
//string rtn = Convert.ToString(GetRequestsCount(id));
//StringBuilder rtn = new StringBuilder();
//rtn.Append(id);
int display = GetRequestsCount(id);
if (!this.IsPostBack) //prevent post back
{
if (string.IsNullOrEmpty(Session["id"].ToString()))
{
Response.Redirect("welcome.aspx", true);
}
else
{
lblUser.Text = Session["FName"].ToString() + " " + Convert.ToString(Session["LName"]) + " {" + id + "}";
Label1.Text = string.Concat(Convert.ToString(display), " New Request(s)");
}
public int GetRequestsCount(string id)
{
string query = "SELECT count(*) FROM TableWHERE username='" + id + "' AND (isActive ='False')";
int count = 0;
try
{
using (SqlConnection thisConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString))
{
using (SqlCommand cmdCount = new SqlCommand(query, thisConnection))
{
thisConnection.Open();
count = (int)cmdCount.ExecuteScalar();
}
}
return count;
}
catch (NullReferenceException ex)
{
throw;
}
}