472,796 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,796 software developers and data experts.

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

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 12 '05 #1
0 9665

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

Similar topics

3
by: Terrence | last post by:
I am doing some of the C# walkthroughs to transition from VB to C#. When I try to execute static void Main() { Aplication.Run(new Form1()) } I raise a 'System.NullReferenceException" in...
7
by: mike p. | last post by:
I have a docbook xml file, and am using standard docbook 1.61.3 xsl stylesheets to do xhtml transform. Transform works fine when using MSXML. When I try to do the following using asp.net 1.1: ...
5
by: Vitling | last post by:
For no apparent reason, a NullReference exception is thrown in system.dll (System.Net.Sockets.OverlappedAsyncResult.CompletionPortCallback). Since I only get a disassembly from Visual Studio, it...
2
by: Raed Sawalha | last post by:
i have a windows form(Main) with listview, when click an item in listview i open other window form (Sub) which generate the selected item from parent window in as treeview items when click any item...
1
by: msnews.microsoft.com | last post by:
I'm trying to fill an array of objects but when I add the first object I get a NullReferenceException. ----------------------------------------------------------------------------...
3
by: PatricQ | last post by:
I use VS.NET and yes I'm a beginner in ASP.NET. Here is the problem: in "%webroot%\components" is the folowing vb code file: framework.vb ---------------------------------------- Imports...
4
by: Terry Mulvany | last post by:
I have a 'BasePage' (BasePage.cs) derived from System.Web.UI.Page that all my pages inherit from. I need to set some properties (either in the OnInit or constructor) based on a potential...
2
by: sxiao | last post by:
Hi, there I got a NullReferenceException when there are more than one users trying to open the same page at the same time. The senerio is: Two users logged into the web application using the...
6
by: William Mild | last post by:
I must be getting brain fried. I can't see the error. Create a new web form with the following code begind: Public Class test Inherits System.Web.UI.Page Public Class ReportCardData ...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.