Can't add parameters in code behind?

Aug 7, 2008 at 3:12 AM

My code is as below:

                PartialUpdatePanel newPanel = new PartialUpdatePanel();
                newPanel.UserControlPath = "~/reportComponents/" + theList.GetString(1);

                String param1= List1.SelectedValue.ToString();
                String param2 = List2.SelectedValue.ToString();

                iucon.web.Controls.Parameter userOU = new iucon.web.Controls.Parameter("myParam", param1);
               
                iucon.web.Controls.Parameter userADsite = new iucon.web.Controls.Parameter("myParam2", param2);

                newPanel.Parameters.Add(userOU);
                newPanel.Parameters.Add(new iucon.web.Controls.Parameter("string","string")); //this was for testing.
                newPanel.Parameters.Add(userADsite);

When I run it I get the error:  NullReferenceException was unhandled by user code
                                            Object reference not set to an instance of an object.
 
And the troubleshooting tips were:
                        Use the "new" keyword to create an object instance.
                        Check to determine if the object is null before calling the method.
                        

Does anyone know what I'm doing wrong?

Thank you,
Keith
                        

Sep 1, 2008 at 1:02 PM
go to control source code

find below lines :
        /// <summary>
        /// Parameters that should be passed via HTTP-GET to the
        /// UserControl
        /// </summary>
        [PersistenceMode(PersistenceMode.InnerProperty)]
        public ParameterCollection Parameters
        {
            get;
            set;
        }

replace them with :

        /// <summary>
        /// Parameters that should be passed via HTTP-GET to the
        /// UserControl
        /// </summary>
        private ParameterCollection _Parameters = new ParameterCollection();
        [PersistenceMode(PersistenceMode.InnerProperty)]
        public ParameterCollection Parameters
        {
            get { return _Parameters; }
            set { _Parameters = value; }
        }

then compile the control again and enjoy with new bin file