Null Exception error - Kindly help me

M

muralidharan

WebForm1.aspx Code:

<%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI"
Assembly="ComponentArt.Web.UI" %> <ComponentArt:TreeView
id="TreeView1" Height="520" AutoPostBackOnNodeMove="false"
DragAndDropEnabled="true"
NodeEditingEnabled="False" KeyboardEnabled="true"
CssClass="TreeView" NodeCssClass="TreeNode"
SelectedNodeCssClass="SelectedTreeNode"
HoverNodeCssClass="HoverTreeNode" NodeEditCssClass="NodeEdit"
LineImageWidth="19" LineImageHeight="20"
DefaultImageWidth="16" DefaultImageHeight="16" ItemSpacing="0"
NodeLabelPadding="3" SpacerImageUrl="/MRCSWebApp/Images/spacer.gif"
CollapseImageUrl="/MRCSWebApp/Images/exp.gif"
ExpandImageUrl="/MRCSWebApp/Images/col.gif"
ParentNodeImageUrl="/MRCSWebApp/Images/folders.gif"
LeafNodeImageUrl="/MRCSWebApp/Images/folder.gif"
ShowLines="true" LineImagesFolderUrl="/MRCSWebApp/Images/lines/"
EnableViewState="true"
ClientScriptLocation="~/client_scripts/componentart_webui_client/"
runat="server"></ComponentArt:TreeView>


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
InitializeComponent()

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
System.Web.UI.WebControls.DataGrid
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
Designer
'Do not modify it using the code editor.
InitializeComponent()
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")
Login(ID)
' End If
End Sub
Public Sub Login(ByVal GID)

Try
Dim objCon As New SqlConnection("Initial Catalog=MRCS;
Data Source=DEVBOX;uid=devuser;pwd=xxxx")
objCon.Open()
' 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
objReader.Read()
If Not objReader.IsDBNull(0) Then
UserID = objReader.GetValue(0)
End If
objReader.Close()

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

buildTree(MenuProfileID)


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
Source=DEVBOX;uid=devuser;pwd=xxxxx")
dbCon.Open()

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
adapter.Fill(ds)
ds.Relations.Add("NodeRelation",
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)
TreeView1.Nodes.Add(newNode)
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)
node.Nodes.Add(childNode)
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
ComponentArt.Web.UI.TreeViewNode
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
object.]
System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +178
System.Web.UI.Control.FindControl(String id) +9
ComponentArt.Web.UI.BaseNavigator.UpdateSelectedNode() +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
Murali.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top