Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8317963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:47:28+00:00 2026-06-08T21:47:28+00:00

I cannot figure out why I any of these methods (load_qc_form(); enable_qc_form();disable_qc_form();) I get

  • 0

I cannot figure out why I any of these methods (load_qc_form(); enable_qc_form();disable_qc_form();) I get the “Message: Object reference not set to an instance of an object.” message.

How can calling a method return null??

Here is my entire code. I am new to C# and am trying to update an existing page. Could someone point me in the right direction?

I want to be able to call these methods from anywhere in the application.

    namespace test_page
{
    using System;
    //using System.Windows.Forms;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using System.Data.SqlClient;


    /// <summary>
    ///     Summary description for ProductionQC.
    /// </summary>
    /// 

    public class hendrix : System.Web.UI.UserControl
    {
        #region class_variable_declarations
        //Test Boxes
        protected System.Web.UI.WebControls.TextBox boxOrder;
        protected System.Web.UI.WebControls.TextBox boxBox;
        protected System.Web.UI.WebControls.TextBox boxPallet;
        protected System.Web.UI.WebControls.TextBox boxPulpTemp;
        protected System.Web.UI.WebControls.TextBox boxComments;
        protected System.Web.UI.WebControls.TextBox boxMajdef1;
        protected System.Web.UI.WebControls.TextBox boxMajdef2;
        protected System.Web.UI.WebControls.TextBox boxMajdef3;
        protected System.Web.UI.WebControls.TextBox boxMindef1;
        protected System.Web.UI.WebControls.TextBox boxMindef2;
        protected System.Web.UI.WebControls.TextBox boxMindef3;
        protected System.Web.UI.WebControls.TextBox boxSamples;
        //drop down lists
        protected System.Web.UI.WebControls.DropDownList listYN;
        protected System.Web.UI.WebControls.DropDownList listMaj1;
        protected System.Web.UI.WebControls.DropDownList listMaj2;
        protected System.Web.UI.WebControls.DropDownList listMaj3;
        protected System.Web.UI.WebControls.DropDownList listMin1;
        protected System.Web.UI.WebControls.DropDownList listMin2;
        protected System.Web.UI.WebControls.DropDownList listMin3;
        protected System.Web.UI.WebControls.DropDownList listRecorder;
        //labels 
        protected System.Web.UI.WebControls.Label lblPalletTag;
        protected System.Web.UI.WebControls.Label lblmajdef1;
        protected System.Web.UI.WebControls.Label lblmajdef2;
        protected System.Web.UI.WebControls.Label lblmajdef3;
        protected System.Web.UI.WebControls.Label lblmindef1;
        protected System.Web.UI.WebControls.Label lblmindef2;
        protected System.Web.UI.WebControls.Label lblmindef3;
        protected System.Web.UI.WebControls.Label lblPulpTemp;
        protected System.Web.UI.WebControls.Label lblComments;
        protected System.Web.UI.WebControls.Label lblPackageCorrect;
        protected System.Web.UI.WebControls.Label lblTotSamples;
        protected System.Web.UI.WebControls.Label lblrecorder;
        //Buttons
        protected System.Web.UI.WebControls.Button btnGo;
        protected System.Web.UI.WebControls.Button btnGo2;
        protected System.Web.UI.WebControls.Button btnGo3;
        protected System.Web.UI.WebControls.Button btnClear;
        //Gridviews
        protected System.Web.UI.WebControls.GridView grdDisplayOrd;
        protected System.Web.UI.WebControls.GridView grdDisplayBox;
        //Data connections - adapters
        protected System.Data.SqlClient.SqlCommand cmdData;
        protected System.Data.SqlClient.SqlConnection sqlConnection1;
        protected System.Data.SqlClient.SqlDataReader dataReader;
        #endregion class_variable_declarations



        private void Page_Load(object sender, System.EventArgs e)
        {
            //initializePage();
            // Put user code to initialize the page here
            if (!this.Page.IsPostBack)
            {
                //load_qc_form();
                //disable_qc_form();

            }

        }

        //private void initializePage()
        // {
        //  throw new NotImplementedException();
        //}


        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
            base.OnInit(e);

        }

        /// <summary>
        ///     Required method for Designer support - do not modify
        ///     the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
            this.btnGo.Click += new System.EventHandler(this.btnGo_Click);
            this.btnGo2.Click += new System.EventHandler(this.btnGo2_Click);
           // this.btnGo3.Click += new System.EventHandler(this.btnGo3_Click);
            this.btnClear.Click += new EventHandler(this.btnClear_Click);

            // 
            // sqlConnection1
            // 
            this.sqlConnection1.ConnectionString = "workstation id=\"******";packet size=4096;user id=******;data source=\"******";persis" +
                "t security info=True;initial catalog=****;password=**********";
            this.Load += new System.EventHandler(this.Page_Load);

        }
        #endregion

       // public virtual string DisplayMember { get; set; }
        //get and display order data
        private void btnGo_Click(object sender, System.EventArgs e)
        {


            {

                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "Select  ord.order_number as Order#,var.description as Description,grd.description as Grade, " +
                                  "size.description as Size,pkg.description as Pkg, ord.container_type as Pallet " +
                                  "FROM t_item_master itm INNER JOIN t_order_detail ord (NOLOCK) ON ord.item_number = itm.item_number " +
                                  "LEFT OUTER JOIN t_package pkg (NOLOCK) ON pkg.package_name = itm.product_package_code " +
                                  "LEFT OUTER JOIN t_grade grd (NOLOCK) ON grd.grade_id = itm.grade_id " +
                                  "LEFT OUTER JOIN t_size size (NOLOCK) ON size.size_id = itm.size_id AND size.package_id = pkg.package_id " +
                                  "LEFT OUTER JOIN t_variety var (NOLOCK) ON var.variety_id = itm.variety_id " +
                                  "WHERE order_number like @order_number";

                cmd.Parameters.Add("@order_number", SqlDbType.VarChar).Value = boxOrder.Text;

                cmd.CommandType = CommandType.Text;
                cmd.Connection = this.sqlConnection1;
                this.sqlConnection1.Open();

                this.grdDisplayOrd.Visible = true;
                SqlDataAdapter adpt = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                adpt.Fill(ds);
                grdDisplayOrd.DataSource = ds;
                grdDisplayOrd.DataBind();

                this.sqlConnection1.Close();
            }

        }
        // get and display box data
        private void btnGo2_Click(object sender, System.EventArgs e)
        {
            {

                load_qc_form();
                SqlCommand cmd = new SqlCommand();
                HyperLink test_link1 = new HyperLink();
                cmd.CommandText = "select " +
                                   "item_number as Item#, " +
                                   "description as Desctiption, " +
                                   "grower_lot as Lot#, " +
                                   "pack_date as Packed " +
                                   "from v_box_data where box_id = @box_id";

                cmd.Parameters.Add("@box_id", SqlDbType.VarChar).Value = boxBox.Text;

                cmd.CommandType = CommandType.Text;
                cmd.Connection = this.sqlConnection1;
                this.sqlConnection1.Open();

                this.grdDisplayBox.Visible = true;
                SqlDataAdapter adpt = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                adpt.Fill(ds);
                grdDisplayBox.DataSource = ds;
                grdDisplayBox.DataBind();

                this.sqlConnection1.Close();
            }
        }
        private void load_qc_form()
        {
            #region declare_variables
           // string pallet_tag;
            //string correct_package;
            //string total_samples;
            //string majdef1;
            //string majdef2;
            //string majdef3;
           // string mindef1;
           // string mindef2;
           // string mindef3;
           // string majcnt1;
           // string majcnt2;
            //string majcnt3;
           // string mincnt1;
           // string mincnt2;
           // string mincnt3;
           // string pulptemp;
           // string comments;
            string recorder;
            #endregion declare_variables

            #region fill_list_recorder
            try
            {
                listRecorder.Items.Clear();

                recorder = "select EMPID,FIRSTNAME+' '+LASTNAME from t_famous_employee " +
                            "where COSTCENTERNAME like 'Quality Control - 2011' " +
                            "and HOMECREWID LIKE 'Shipping' ";


                cmdData = new System.Data.SqlClient.SqlCommand(recorder, this.sqlConnection1);
                cmdData.Connection = this.sqlConnection1;
                this.sqlConnection1.Open();
                SqlDataAdapter da = new SqlDataAdapter(cmdData);
                DataTable dt = new DataTable();
                da.Fill(dt);
                listRecorder.DataBind();


                    listRecorder.DataSource = dt;
                    listRecorder.DataValueField = "EMPID";
                    listRecorder.DataTextField = "FIRSTNAME+' '+LASTNAME";
                    this.listRecorder.Items.Insert(0, "FIRSTNAME+' '+LASTNAME");

            }
            catch (Exception) { }
            this.dataReader.Close();

            #endregion


        }

        private void btnGo3_Click(object sender, System.EventArgs e)
        {
            {

            }

        }

        private void btnClear_Click(object sender, System.EventArgs e)
        {
            {
                this.boxOrder.Text = "";
                this.boxBox.Text = "";
                this.grdDisplayOrd.Visible = false;
                this.grdDisplayBox.Visible = false;
                //disable_qc_form();
            }
        }
        private void enable_qc_form()
        {
             this.listMaj1.Enabled = true;
            this.listMaj2.Enabled = true;
            this.listMaj3.Enabled = true;
            this.listMin1.Enabled = true;
            this.listMin2.Enabled = true;
            this.listMin3.Enabled = true;
            this.listYN.Enabled = true;
            this.listMaj1.Enabled = true;
            this.listMaj2.Enabled = true;
            this.listMaj3.Enabled = true;
            this.listMin1.Enabled = true;
            this.listMin2.Enabled = true;
            this.listMin3.Enabled = true;
            this.boxComments.Enabled = true;
            this.boxMajdef1.Enabled = true;
            this.boxMajdef2.Enabled = true;
            this.boxMajdef3.Enabled = true;
            this.boxMindef1.Enabled = true;
            this.boxMindef2.Enabled = true;
            this.boxMindef3.Enabled = true;
            this.boxPallet.Enabled = true;
            this.boxPulpTemp.Enabled = true;
            this.boxSamples.Enabled = true;
            this.lblComments.Enabled = true;
            this.lblmajdef1.Enabled = true;
            this.lblmajdef2.Enabled = true;
            this.lblmajdef3.Enabled = true;
            this.lblmindef1.Enabled = true;
            this.lblmindef2.Enabled = true;
            this.lblmindef3.Enabled = true;
            this.lblPackageCorrect.Enabled = true;
            this.lblPalletTag.Enabled = true;
            this.lblPulpTemp.Enabled = true;
            this.lblTotSamples.Enabled = true;
        }
        private void disable_qc_form()
        {
                this.listMaj1.Enabled = false;
                this.listMaj2.Enabled = false;
                this.listMaj3.Enabled = false;
                this.listMin1.Enabled = false;
                this.listMin2.Enabled = false;
                this.listMin3.Enabled = false;
                this.listYN.Enabled = false;
                this.listMaj1.Enabled = false;
                this.listMaj2.Enabled = false;
                this.listMaj3.Enabled = false;
                this.listMin1.Enabled = false;
                this.listMin2.Enabled = false;
                this.listMin3.Enabled = false;
                this.boxComments.Enabled = false;
                this.boxMajdef1.Enabled = false;
                this.boxMajdef2.Enabled = false;
                this.boxMajdef3.Enabled = false;
                this.boxMindef1.Enabled = false;
                this.boxMindef2.Enabled = false;
                this.boxMindef3.Enabled = false;
                this.boxPallet.Enabled = false;
                this.boxPulpTemp.Enabled = false;
                this.boxSamples.Enabled = false;
                this.lblComments.Enabled = false;
                this.lblmajdef1.Enabled = false;
                this.lblmajdef2.Enabled = false;
                this.lblmajdef3.Enabled = false;
                this.lblmindef1.Enabled = false;
                this.lblmindef2.Enabled = false;
                this.lblmindef3.Enabled = false;
                this.lblPackageCorrect.Enabled = false;
                this.lblPalletTag.Enabled = false;
                this.lblPulpTemp.Enabled = false;
                this.lblTotSamples.Enabled = false;
            }


        }

    }

So I need to be able to call the method to test my first dropdown list.

Thank you in advance for your help!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:47:30+00:00Added an answer on June 8, 2026 at 9:47 pm

    The problems was there was a typo in the form ascx page. So essentially I was declaring a box that didn’t exist!! As with most programming problem the devil is in the details!! Thank you all for your help. As it turns out I just need to learn how to type!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cannot figure out how to get rid of errors that should not be
I cannot figure out why I get this error during check-in. I checked in
I cannot figure out what my object instance names are because of how I
I cannot figure out how to set an estimated maximum price for a collection
Cannot figure out, where to change EOF in PyCharm. My scripts start with :
I cannot figure out this positioning problem in Firefox. It doesn't seem to follow
I cannot figure out why this doesn't work. It seems so simple. It should
I cannot figure out how to write the following query using the DbFinderPlugin 1.2.2
I cannot figure out how to convert this code from C# to VB.net. It
I cannot figure out what is obscuring my buttons. The first image shows the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.