473,385 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Object reference not set to an instance of an object.

"Object reference not set to an instance of an object."

I had receive the above mention error I have load printer info in first combo box and when select value a event triggered and load values in second combo box using printer info but i am receiving subject mention error.
Expand|Select|Wrap|Line Numbers
  1. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2.         'txtUPCode.Attributes.Add("onclick", "showDiv('divQtyAddSidebar');")
  3.         'txtUPCode.Attributes.Add("onfocus", "showDiv('divQtyAddSidebar');")
  4.         'txtUPCode.Attributes.Add("onblur", "hideDiv('divQtyAddSidebar', this.value);")
  5.  
  6.         txtProductSearch.Attributes.Add("onfocus", "showDiv('divSearchSidebar');")
  7.         txtProductSearch.Attributes.Add("onblur", "hideDiv('divSearchSidebar', this.value);")
  8.  
  9.  
  10.  
  11.         If Not IsPostBack Then
  12.             ''Load Brand Name
  13.             ddlSelectBrand.DataSource = wseCommerce.LoadBrand().Tables(0)
  14.             ddlSelectBrand.DataTextField = wseCommerce.LoadBrand().Tables(0).Columns("ManufacturerName").ColumnName.ToString()
  15.             ddlSelectBrand.DataValueField = wseCommerce.LoadBrand().Tables(0).Columns("ManufacturerCode").ColumnName.ToString()
  16.             ddlSelectBrand.DataBind()
  17.         End If
  18.  
  19.         LoadPageStateFromPersistenceMedium()
  20.     End Sub
  21.  
  22.     Protected Sub ddlSelectBrand_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlSelectBrand.SelectedIndexChanged
  23.         If ddlSelectBrand.SelectedValue <> "" Then
  24.             ddlSelectCatridge.Enabled = True
  25.             ddlSelectPrinter.Enabled = True
  26.  
  27.             'Load Printer against Brand Name
  28.             Dim BrandName As String = ddlSelectBrand.SelectedItem.Text.ToString
  29.             ddlSelectPrinter.DataSource = wseCommerce.LoadPrinter(BrandName).Tables(0) 'error Object reference not set to an instance of an object. 
  30.             ddlSelectPrinter.DataValueField = wseCommerce.LoadPrinter(BrandName).Tables(0).Columns("PrinterName").ColumnName.ToString()
  31.             ddlSelectPrinter.DataTextField = wseCommerce.LoadPrinter(BrandName).Tables(0).Columns("PrinterName").ColumnName.ToString()
  32.             ddlSelectPrinter.DataBind()
  33.         Else
  34.             ddlSelectCatridge.Enabled = False
  35.             ddlSelectPrinter.Enabled = False
  36.         End If
  37.     End Sub
Sep 6 '10 #1
2 1364
mzmishra
390 Expert 256MB
did you check if this statement has any tables . wseCommerce.LoadPrinter(BrandName)
Sep 7 '10 #2
Frinavale
9,735 Expert Mod 8TB
ASP.NET runs in a stateless environment. That means that when a request to the page occurs (whether it be the first time the page is loaded or because of a postback) all of the objects required in order to process the page are created...and when the response is sent to the browser, everything is destroyed.

This means that wseCommerce does not exist unless you recreate it on subsequent page requests. It might be a good idea to store the results in Session or something so that you don't have to recreate it by connecting to the database.

-Frinny
Sep 7 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Pkpatel | last post by:
Hi, I keep getting this error every time I try to load crystalreportviewer on a webform with a dataset. Here is the error: -------------------------------------------------------- Server...
6
by: NewToDotNet | last post by:
I am getting "Object reference not set to an instance of an object. " when I attempt to open a C# windows service class in design view, although I was able to initially create the service and open...
4
by: Frawls | last post by:
Hi, I get the following error when trying to run a search on my aspx site, this error only occours if the product im searching for does not exist. Can anybody explain this please and help me...
6
by: blash | last post by:
Can someone help me? I really don't have a clue. My company staff told me they often got such error: "Object reference not set to an instance of an object." when they are in search result page...
2
by: jw56578 | last post by:
why am i getting the "Object reference not set to an instance of an object" error on all page registeration tags in my project. <%@ Page Language="vb" AutoEventWireup="false"...
3
by: nemo | last post by:
Hi, My application works fine on the localhost but spits this error as soon as I put it on the server. I know this error occurs when an object has not been instantiated prior to a reference, but...
3
by: Adam | last post by:
We have a web site that uses .vb for the web pages and .cs for a class module. We are getting the error in .NET 2.0 and VS 2005 beta 2. It does work with .NET 1.1. When trying to access a page...
6
by: kalaivanan | last post by:
hi, i am a beginner in c#. i have theoretical knowledge about object, reference and instance. but i want to know clearly about what is an object, reference and instance. can any one help me? or...
1
by: vishnu | last post by:
Hi, I am working on asp.net project which I converted the code fron VB to C# and instead of RaiseEvent in VB code I used the following code. using System; using System.Data; using...
4
by: livmacca | last post by:
Hi, I am new to VB .Net programming and is trying to create a webpage. I encountered the following error and is totally clueless on how to make it work: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.