I know this would be thrown if trying to access an object that's null, but it's only happening sporadically which makes it hard to test. This error is emailed to me, and it doesn't have the line number in it, not sure why. That would help.
System.NullReferenceException: Object reference not set to an instance of an object.
at SC.WebModules.Cars.Web.SearchResults.Page_Load(Object sender, EventArgs e)...
System.NullReferenceException: Object reference not set to an instance of an object.
at SC.WebModules.Cars.Web.SearchResults.Page_Load(Object sender, EventArgs e)...
Code:
private void Page_Load(object sender, System.EventArgs e)
{
Message.InnerHtml = "";
if (Session["Message"] != null)
{
Message.InnerHtml = Session["Message"].ToString();
Session.Remove("Message");
}
if (Session["dvProfiles"] != null && ((DataView)Session["dvProfiles"]).Count > 0)
{
if (Request.UrlReferrer.AbsolutePath.IndexOf("SendEmail.aspx") != -1 && Session["SavedPageIndex"] != null)
{
ProfilesGrid.CurrentPageIndex = (int)Session["SavedPageIndex"];
}
ProfilesGrid.DataSource = (DataView)Session["dvProfiles"];
ProfilesGrid.DataBind();
}
else
{
Message.InnerHtml = "No profiles matched your search criteria.";
searchAgain.Visible = false;
}
}