Operator is not valid for type 'ArrayList' and string "".

M

Marc Bishop

can anyone help me with this?

Code Snippet:
Dim ArrCart As New ArrayList()
if NOT Session("sesCart") = "" then
ArrCart = Session("sesCart")

Error:
System.InvalidCastException: Operator is not valid for type 'ArrayList' and
string "".
Line 26: if NOT Session("sesCart") = "" then

Thanks in advance
marc
 
C

Codemonkey

Marc,

I see two potential mistakes in this code.
Dim ArrCart As New ArrayList()

Here, you are creating an instance of an arraylist. This is fine

ArrCart = Session("sesCart")

Here you are assigning whatever is in 'Session("sesCart")' to 'ArrCart',
overwriting the instance that you declared above.

The error is probably being raised because 'Session("sesCart")' does not
contain an instance of an arraylist - it looks like it contains a string
instead. Make sure of what you are assigning to your variables.

Hope this helps,

Trev.
 

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,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top