473,473 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Null Exception error - Kindly help me

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.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
Murali.
Nov 18 '05 #1
0 1564

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chris Herring | last post by:
Hi there: Well, let me start off by saying that I am a Visual Studio drag and drop weenie, not a real programmer. So I tend to get confused when things do not look like the instructions said they...
4
by: rrober07 | last post by:
Hello, My Setup is I have a Web Server machine(Devweb01), Database SQL Machine(Devsql01), a Client Machine(local machine) I have configured the SQL machine as follows: 1) Added local Aspnet...
2
by: Jim McGivney | last post by:
In asp 2.0 I am trying to insert a row using a detailsview control connected to an accessDataSource. I get the error message below. I am having trouble identifing which data field is causing the...
2
by: paul.dunstone | last post by:
HI all I am using msbuild to compile my web application project. After building the solution I get the following error message: Server Error in '/Community' Application....
10
by: pauldepstein | last post by:
I have read about exception handling in a few books and websites but am still confused on a basic point. I understand the try ... catch syntax. However, I have seen examples of using throw...
132
by: Zorro | last post by:
The simplicity of stack unraveling of C++ is not without defective consequences. The following article points to C++ examples showing the defects. An engineer aware of defects can avoid...
0
by: amitpatil | last post by:
I am having trouble with following error. there are few registration page when i register 2 members it works but when i try to create 3rd one i get following error and then for 10 mins or so website...
0
by: buntyindia | last post by:
Hi, I have a very strange problem with my application. I have developed it using Struts. I have a TextBox With Some fixed value in it and on Submit iam passing it to another page. <html:form...
2
by: crabsdf | last post by:
My project is a single method class which takes a xml object and, using Apache FOP, transforms it into a PDF which is returned as an output stream. Here is full code package...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.