J
John A. Fuqua
I am getting the following error when trying to set the datasource for
my datagrid control:
"Object reference not set to an instance of an object"
Here is the code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace WebRegistration
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.TextBox txtAccount;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Panel Step1Panel;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Panel Step2Panel;
protected System.Web.UI.WebControls.TextBox txtCSA_ShipToPostalCode;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.DataGrid dgCustomers;
protected System.Web.UI.WebControls.Label Label2;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#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.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
iGoBusinessManager.EntityObjects.ObjectFactory theFactory =
new iGoBusinessManager.EntityObjects.ObjectFactory();
iGoBusinessManager.EntityObjects.Interfaces.ICustomerManager
theCustomerManager =
(iGoBusinessManager.EntityObjects.Interfaces.ICustomerManager)theFactory.getInstance("CustomerManager");
IList customerList =
theCustomerManager.FindbyExample(Step1Panel.Controls.GetEnumerator(),
"Locations");
dgCustomers.DataSource = customerList;
Step2Panel.Visible = true;
Step1Panel.Visible = false;
}
}
}
my datagrid control:
"Object reference not set to an instance of an object"
Here is the code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace WebRegistration
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.TextBox txtAccount;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Panel Step1Panel;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Panel Step2Panel;
protected System.Web.UI.WebControls.TextBox txtCSA_ShipToPostalCode;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.DataGrid dgCustomers;
protected System.Web.UI.WebControls.Label Label2;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#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.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
iGoBusinessManager.EntityObjects.ObjectFactory theFactory =
new iGoBusinessManager.EntityObjects.ObjectFactory();
iGoBusinessManager.EntityObjects.Interfaces.ICustomerManager
theCustomerManager =
(iGoBusinessManager.EntityObjects.Interfaces.ICustomerManager)theFactory.getInstance("CustomerManager");
IList customerList =
theCustomerManager.FindbyExample(Step1Panel.Controls.GetEnumerator(),
"Locations");
dgCustomers.DataSource = customerList;
Step2Panel.Visible = true;
Step1Panel.Visible = false;
}
}
}