troubleshooting Question

Object reference not set... asp 4

Avatar of Mike Eghtebas
Mike EghtebasFlag for United States of America asked on
.NET ProgrammingASP.NETVisual Basic.NET
9 Comments1 Solution295 ViewsLast Modified:
The list box in question is:
<asp:ListBox ID="lstEducation" runat="server" Width="205px">
                        <asp:ListItem >High School</asp:ListItem>
                        <asp:ListItem>Associate&#39;s Degree</asp:ListItem>
                        <asp:ListItem>Four-Year College</asp:ListItem>
This error occurs in page load at:

lstEducation.SelectedItem.Text = Session("education")

The intelesens shows a valid choice for the session variable.  
Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 

Line 62:             ddlMaterialStatus.SelectedItem.Text = Session("maritalStatus")
Line 63: 
Line 64:             lstEducation.SelectedItem.Text = Session("education")
Line 65:             chkAddComment.Checked = Session("addComment")
Line 66:             txtComment.Text = Session("comment")

Stack Trace: 

[NullReferenceException: Object reference not set to an instance of an object.]
   addContact.Page_Load(Object sender, EventArgs e) in ... AddContact.aspx.vb:64
   System.Web.UI.Control.OnLoad(EventArgs e) +91
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
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 9 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