troubleshooting Question

How to display Check in CheckBox Control

Avatar of asp_net2
asp_net2Flag for United States of America asked on
.NET ProgrammingASP.NET
5 Comments1 Solution266 ViewsLast Modified:
Hello EE,

I have the following CodeBehind below and I would like to display a Check in my CheckBox Control during Page_Load if the value for the CheckBox Control is 1 in the DB.

 protected void Page_Load(object sender, EventArgs e)
        hf_AppID.Value = Session["pi_id"].ToString();

        if (!IsPostBack)
            int pi_id = Convert.ToInt32(Session["pi_id"]);

            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["WellnessChoice"].ConnectionString);

            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "WellnessChoice_RetrieveAnnualPhysicalValuesByPI_ID";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = conn;

            cmd.Parameters.AddWithValue("@pi_id", SqlDbType.Int).Value = pi_id;

            DataTable dtModify = new DataTable("Modify");

            SqlDataAdapter adp = new SqlDataAdapter();


                adp.SelectCommand = cmd;

                if ((dtModify != null))
                    DataRow data = dtModify.Rows[0];
                    hf_ap_id.Value = data["ap_id"].ToString();
                    txtPhysicalDateCompleted.Text = Convert.ToDateTime(data["ap_date"]).ToShortDateString();
                    lblFileNameUploaded.Text = "Your File has been uploaded: " + data["ap_pdf_filename"].ToString();

                    if (data["ap_section_complete"].ToString() == "1")
                        btn_SaveAnnualPhysical.Enabled = false;

            catch (Exception ex)

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros