protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { try { if (Session[Constants.userId].ToString() != null || Session[Constants.userId].ToString() != "") { lblUserId.Text = Session[Constants.userId].ToString(); } else { throw new NullReferenceException(); } lblUserId.Visible = false; Session[Constants.userId] = lblUserId.Text; BloodBL bl = new BloodBL(); List <string> states = bl.GetStateFromHospitalById(int.Parse(lblUserId.Text)); ddlState.DataSource = states; ddlState.DataBind(); ddlState.Items.Insert(0, "Select State"); } catch (Exception ee) { Response.Write("<script>alert('Your session expired...Please login again');window.location.href='HomePageBeforeLogin.aspx'</script>"); } } }