I am getting this error when trying to add typed object "Questions" to
Arraylist QuestionsList:
Object reference not set to an instance of an object.
--> r.QuestionsList.Add(q);
I tried using r.QuestionsList.Add(q) to add a new instance within the
loop but it does not work. Any help will be appreciated...
namespace Quotes
{
public class Registration : Address
{
public Registration()
{
//
// TODO: Add constructor logic here
//
}
private string _categoryID;
public string categoryID
{
get { return _categoryID; }
set { _categoryID = value; }
}
private ArrayList _QuestionsList;
public ArrayList QuestionsList
{
get { return _QuestionsList; }
set { _QuestionsList = value; }
}
}
}
get_address.aspx
protected void Page_Load(object sender, EventArgs e)
{
// GET QUESTIONS INFO
// Loop PostBack Fields from another page
// Checks if Registration contains previouslly saved data
if (Session["RegistrationInfo"] != null)
{
Registration r = new Registration();
r = (Registration)Session["RegistrationInfo"];
foreach (string sName in Request.Form)
{
if (sName.IndexOf("rc") > -1)
{
Questions q = new Questions();
q.QuestionID = sName;
q.Answer = Request.Form[sName];
r.QuestionsList.Add(q); // *** ERROR HERE
}
}
r = (Registration)Session["RegistrationInfo"];
}
}
namespace Quotes
{
public class Questions
{
public Questions()
{
//
// TODO: Add constructor logic here
//
}
private string _QuestionID;
public string QuestionID
{
get { return _QuestionID; }
set { _QuestionID = value; }
}
private string _Answer;
public string Answer
{
get { return _Answer; }
set { _Answer = value; }
}
}
THANKS
Rod