473,394 Members | 1,724 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,394 software developers and data experts.

Storing an array to a Session

I am storing an array which contains about a dozen chracter items to a
Session variable. Later, I need to use this array so I am doing the
following:

Dim eventTypes As String() = DirectCast(Session("EventTypes"), String())
If Date.Today <= closeDate Then
If eventTypes(cblEntries.SelectedIndex) = "J" Then thisFee =
Session("JRFee") Else thisFee = Session("PEFee")
Else
If eventTypes(cblEntries.SelectedIndex) = "J" Then thisFee =
Session("JRFee") Else thisFee = Session("DOSFee")
End If

I have determined that the values are properly being stored into the initial
array. I then assign a session variable to store this array. When I try to
use the array in the segment above, I get the error "Object reference not set
to an instance of an object - use the "new keyword".

Obviously when I dim the eventTypes() something is wrong here. Please help.

Thanks for the information.
Dec 22 '05 #1
3 2314
Either a new session is being started, or you are not retrieving the data
using the same session variable name, or something like that.

Basically, your variable references nothing after the assignment.

"Brad" <Br**@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
I am storing an array which contains about a dozen chracter items to a
Session variable. Later, I need to use this array so I am doing the
following:

Dim eventTypes As String() = DirectCast(Session("EventTypes"), String())
If Date.Today <= closeDate Then
If eventTypes(cblEntries.SelectedIndex) = "J" Then thisFee =
Session("JRFee") Else thisFee = Session("PEFee")
Else
If eventTypes(cblEntries.SelectedIndex) = "J" Then thisFee =
Session("JRFee") Else thisFee = Session("DOSFee")
End If

I have determined that the values are properly being stored into the
initial
array. I then assign a session variable to store this array. When I try
to
use the array in the segment above, I get the error "Object reference not
set
to an instance of an object - use the "new keyword".

Obviously when I dim the eventTypes() something is wrong here. Please
help.

Thanks for the information.

Dec 22 '05 #2
If you have the array in the session I would do this:

Dim EventTypes as String()
EventTypes = Session("EventTypes")

If for some reason that doesn't work just put this line in the middle to try
(I know it's nuts but try it)
Redim EventTypes(0)

Make sure that Date.Today, cblEntries.SelectedIndex and Session("PEFee")
etc. all exist. The problem might not be the array, but the message isn't
reveailing it.

I am fairly certain that I have done this in the past with no ill effects.

"Brad" <Br**@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
I am storing an array which contains about a dozen chracter items to a
Session variable. Later, I need to use this array so I am doing the
following:

Dim eventTypes As String() = DirectCast(Session("EventTypes"), String())
If Date.Today <= closeDate Then
If eventTypes(cblEntries.SelectedIndex) = "J" Then thisFee =
Session("JRFee") Else thisFee = Session("PEFee")
Else
If eventTypes(cblEntries.SelectedIndex) = "J" Then thisFee =
Session("JRFee") Else thisFee = Session("DOSFee")
End If

I have determined that the values are properly being stored into the
initial
array. I then assign a session variable to store this array. When I try
to
use the array in the segment above, I get the error "Object reference not
set
to an instance of an object - use the "new keyword".

Obviously when I dim the eventTypes() something is wrong here. Please
help.

Thanks for the information.

Dec 22 '05 #3
Thank you both for the information, but for some reason it still does not
work. However, with a lot of things, I did a work-around and I am not using
an array. I am just doing some string manipulation and comparing the string.

I still would like to get the array to work, however.

Thanks again.

"Roger Twomey" wrote:
If you have the array in the session I would do this:

Dim EventTypes as String()
EventTypes = Session("EventTypes")

If for some reason that doesn't work just put this line in the middle to try
(I know it's nuts but try it)
Redim EventTypes(0)

Make sure that Date.Today, cblEntries.SelectedIndex and Session("PEFee")
etc. all exist. The problem might not be the array, but the message isn't
reveailing it.

I am fairly certain that I have done this in the past with no ill effects.

"Brad" <Br**@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
I am storing an array which contains about a dozen chracter items to a
Session variable. Later, I need to use this array so I am doing the
following:

Dim eventTypes As String() = DirectCast(Session("EventTypes"), String())
If Date.Today <= closeDate Then
If eventTypes(cblEntries.SelectedIndex) = "J" Then thisFee =
Session("JRFee") Else thisFee = Session("PEFee")
Else
If eventTypes(cblEntries.SelectedIndex) = "J" Then thisFee =
Session("JRFee") Else thisFee = Session("DOSFee")
End If

I have determined that the values are properly being stored into the
initial
array. I then assign a session variable to store this array. When I try
to
use the array in the segment above, I get the error "Object reference not
set
to an instance of an object - use the "new keyword".

Obviously when I dim the eventTypes() something is wrong here. Please
help.

Thanks for the information.


Dec 22 '05 #4

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

Similar topics

2
by: Francisco | last post by:
I have this problem: I have a database with information about games, and users are able to vote for them. Everytime a user votes for a game I store the unique game name into a session variable (an...
4
by: mechweb | last post by:
Hi all, I can successfully store an array in a session variable like so: string arr1 = new string; Session = arr1; But, when I try to display the elements (using the code below) on another...
2
by: jakk | last post by:
Below is the exception that Iam getting. It says that the DataView that Iam storing in the session is not Serializable. BUt works fine if I store in the inproc session and fails if I switch to...
10
by: Mark Rae | last post by:
Hi, This relates to the previous thread "Disappearing Sessions", but is a bit more generic so I thought I'd start a new thread. This one relates to the storing of objects in Session once only to...
0
by: toton | last post by:
Hi, I have a little design related problem, and finding a good way to resolve it. To state the problem, I have points from writing of several documents. Each document represents a Session class ,...
1
by: None | last post by:
Hi, I have developed webshop application using asp.net 1.1. I'm using DataGrid in one of the pages of my site. During the page load the DataGrid will be binded by around 7500 products(rows). At...
3
by: RSH | last post by:
Hi, I have a situation where I have created an object that contains fields,properties and functions. After creating the object I attempted to assign it to a session variable so i could retrieve...
6
by: J055 | last post by:
Hi I have the following code. I upload an XML file using the FileUpload object, store the stream in a session so the user gets the chance to confirm some options then pass the stream from the...
3
by: Astha | last post by:
Hello ..I am new to asp.net .I have this problem of storing session values in a variable as an array.That is ..an array should contain the session values.How am i to do this in C#?and how can I...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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,...
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...
0
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...

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.