Im getting a NullReferenceException when I goto add a product to my cart, i get the error when i come to this part - cart.AddProduct(productnumber, name, price, prodQty, knobColor, finishColor)
I use extremely similar code in another one of my projects and do not come across this problem, I have also researched it for a while and still came across no soltuion. - Protected Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
-
-
Dim cart As New Cart
-
cart = Session("Cart")
-
-
-
Dim flag As Integer = 1
-
Dim finishColor As String = ""
-
Dim knobColor As String = ""
-
Dim prodQty As Integer = 0
-
Dim price As Decimal = 0
-
Dim name As String = ""
-
Dim productnumber As Integer = 0
-
-
If txtQty.Text = "" Then
-
lblError.Text = "Please enter a numeric quantity."
-
ElseIf Not IsNumeric(txtQty.Text) Then
-
lblError.Text = "Please enter a numeric quantity."
-
Return
-
ElseIf Not Integer.Parse(txtQty.Text) > 0 Then
-
lblError.Text = "Please enter a integer numeric quantity."
-
Return
-
End If
-
-
If Not txtQty.Text = "" Then
-
productnumber = prodID
-
name = lblName.Text
-
price = lblPrice.Text
-
prodQty = txtQty.Text
-
finishColor = DDFinish.SelectedItem.Text
-
knobColor = DDKnob.SelectedItem.Text
-
-
cart.AddProduct(productnumber, name, price, prodQty, knobColor, finishColor)
-
-
-
End If
-
-
Session("Cart") = cart
class that this sends to - cart.AddProduct(productnumber, name, price, prodQty, knobColor, finishColor)
: - <Serializable()> Public Class Cart
-
Dim Prods As New ArrayList
-
-
Public Sub AddProduct(ByVal _ProductNumber As Integer, ByVal _Name As String, ByVal _Price As Decimal, ByVal _Quantity As Integer, ByVal _knob As String, ByVal _finish As String)
-
Dim Item As New ProductClass2
-
Item.pID = _ProductNumber
-
Item.Name = _Name
-
Item.Price = _Price
-
Item.Quantity = _Quantity
-
Item.Knob = _knob
-
Item.Finish = _finish
-
-
Prods.Add(Item)
-
End Sub
1 1086
Hi firebirds98,
If you add a break point on the line where you call AddProduct do all the variables that you are pass to the sub have a value?
Is it actually this line that's causing the exception or can you step inside the sub and find the line inside it that's causing the error?
By the way, you've posted your question in the Classic ASP forum. As you are obviously working with ASP.NET please post all future questions in the .NET forum where you'll receive better help.
Dr B
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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:
...
|
by: muralidharan |
last post by:
WebForm1.aspx Code:
<%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI"
Assembly="ComponentArt.Web.UI" %> <ComponentArt:TreeView
id="TreeView1" Height="520"...
|
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...
|
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.
----------------------------------------------------------------------------...
|
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...
|
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
...
|
by: Craig |
last post by:
This is killing me, I've been trying to figure this out for 2 days.
When I click on the linkbutton, it executes the GetData(int) method to set
the DataSource. The FAILURE is when it tries to...
|
by: sqlguy |
last post by:
I am using a vendor package written in .net 2.0 C#. They say it works well,
and that I may have a configuration issue. The error I am getting is shown
below. Searching ms and google, it seems...
|
by: Zytan |
last post by:
I just got the strangest error. I have exception code that catches a
null reference exception:
catch (NullReferenceException ex) { ... }
The handling code does nothing but print out data from...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |