By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,686 Members | 2,589 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,686 IT Pros & Developers. It's quick & easy.

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

P: n/a
WebForm1.aspx Code:

<%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI"
Assembly="ComponentArt.Web.UI" %> <ComponentArt:TreeView
id="TreeView1" Height="520" AutoPostBackOnNodeMove="false"
NodeEditingEnabled="False" KeyboardEnabled="true"
CssClass="TreeView" NodeCssClass="TreeNode"
HoverNodeCssClass="HoverTreeNode" NodeEditCssClass="NodeEdit"
LineImageWidth="19" LineImageHeight="20"
DefaultImageWidth="16" DefaultImageHeight="16" ItemSpacing="0"
NodeLabelPadding="3" SpacerImageUrl="/MRCSWebApp/Images/spacer.gif"
ShowLines="true" LineImagesFolderUrl="/MRCSWebApp/Images/lines/"
BackEnd Code:

Imports MRCS_Class.FileUtilities
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlTypes
Imports System.Data.OleDb
Imports MRCS_Class.LoginClass
Imports MRCSWebApp.Welcome
Imports System.Data.SqlDbType
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports MRCS_Class.Search
Imports ComponentArt.Web.UI
Public Class AdvancedSearch
Inherits System.Web.UI.Page
Public objDataReader As IDataReader

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub

End Sub
Protected WithEvents TreeView1 As ComponentArt.Web.UI.TreeView
Protected WithEvents MRN As System.Web.UI.WebControls.TextBox
Protected WithEvents SSN As System.Web.UI.WebControls.TextBox
Protected WithEvents Lname As System.Web.UI.WebControls.TextBox
Protected WithEvents Fname As System.Web.UI.WebControls.TextBox
Protected WithEvents DOB As System.Web.UI.WebControls.TextBox
Protected WithEvents AdvancedGrid As
Protected WithEvents AdvSearch As System.Web.UI.WebControls.Button

'NOTE: The following placeholder declaration is required by the
Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form
'Do not modify it using the code editor.
End Sub

#End Region
Dim oConn As SqlConnection
Dim objReader As IDataReader
Public UserID As Int16
Dim FetchType As String
Dim oDS As New DataSet
Dim DView As DataView
Dim MenuID As Integer
Dim MenuProfileID As Integer

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
' If Not IsPostBack = True Then
ID = Request("GUID")
' End If
End Sub
Public Sub Login(ByVal GID)

Dim objCon As New SqlConnection("Initial Catalog=MRCS;
Data Source=DEVBOX;uid=devuser;pwd=xxxx")
' Set Command object properties
Dim objCmd As New SqlCommand
Dim objCmd1 As New SqlCommand
With objCmd
.Connection = objCon
.CommandText = "procLogin_RetreiveSession"
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@SESSIONID", SqlDbType.VarChar,
255).Value = GID
End With
objReader = objCmd.ExecuteReader
If Not objReader.IsDBNull(0) Then
UserID = objReader.GetValue(0)
End If

With objCmd1
.Connection = objCon
.CommandText = "procProfileDetail_Retreive"
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@UserID", SqlDbType.BigInt).Value =
End With
objDataReader = objCmd1.ExecuteReader
If Not objDataReader.IsDBNull(0) Then
MenuProfileID = objDataReader.GetValue(0)
End If

Catch ex As Exception
Dim clsError As MRCS_Class.FileUtilities
clsError = New MRCS_Class.FileUtilities
With clsError
.CreateErrorLog(Err.Number, Err.Description)
End With
End Try
End Sub
' Build Tree, Populate Sub Tree and Create Node are Used to create
the tree
Private Sub buildTree(ByVal MenuProfileID)

Dim dbCon As New SqlConnection("Initial Catalog=MRCS; Data

Dim adapter As New SqlDataAdapter("SELECT * FROM tblMenu LEFT
OUTER JOIN tblMenuProfileDetails ON tblMenu.MenuID =
tblMenuProfileDetails.MenuID WHERE tblMenuProfileDetails.MenuProfileID
=" & MenuProfileID & "OR tblMenu.ParentNodeID IS NULL OR
tblMenu.ParentNodeID = 1 ORDER BY tblMenu.MenuID ASC", dbCon)
Dim ds As New System.Data.DataSet
ds.Tables(0).Columns("MenuID"), ds.Tables(0).Columns("ParentNodeID"))
Dim dbRow As System.Data.DataRow
For Each dbRow In ds.Tables(0).Rows
If (dbRow.IsNull("ParentNodeID")) Then
Dim newNode As ComponentArt.Web.UI.TreeViewNode
newNode = CreateNode(dbRow("Text").ToString(),
dbRow("ImageURL").ToString(), dbRow("RefURL").ToString(), True)
PopulateSubTree(dbRow, newNode)
End If
Next dbRow

End Sub
' Build Tree, Populate Sub Tree and Create Node are Used to create
the tree
Private Sub PopulateSubTree(ByVal dbRow As System.Data.DataRow,
ByVal node As ComponentArt.Web.UI.TreeViewNode)
Dim childRow As System.Data.DataRow
For Each childRow In dbRow.GetChildRows("NodeRelation")
Dim childNode As ComponentArt.Web.UI.TreeViewNode
childNode = New ComponentArt.Web.UI.TreeViewNode
childNode = CreateNode(childRow("Text").ToString(),
childRow("ImageURL").ToString(), childRow("RefURL").ToString(), True)
PopulateSubTree(childRow, childNode)
Next childRow
End Sub
' Build Tree, Populate Sub Tree and Create Node are Used to create
the tree
Private Function CreateNode(ByVal text As String, ByVal imageurl
As String, ByVal refurl As String, ByVal expanded As Boolean) As
Dim MsgID As Integer
Dim PID As Integer
Dim MsgType As String
Dim node As ComponentArt.Web.UI.TreeViewNode
node = New ComponentArt.Web.UI.TreeViewNode
node.Text = text
node.ImageUrl = imageurl
node.Expanded = expanded
node.NavigateUrl = refurl & "?MsgID=" & Request("MsgID") &
"&PID=" & Request("PID") & "&MsgType=" & Request("MsgType") & "&GUID="
& Request("GUID")

Return node
End Function

This returns a error as below:

Server Error in '/MRCSWebApp' Application.

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:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +178
System.Web.UI.Control.FindControl(String id) +9
ComponentArt.Web.UI.BaseNavigator.UpdateSelectedNo de() +127
ComponentArt.Web.UI.BaseNavigator.OnLoad(EventArgs e) +290
ComponentArt.Web.UI.TreeView.OnLoad(EventArgs e) +19
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Page.ProcessRequestMain() +731
Kindly help me out.
Thank you
Nov 12 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.