how to assign session object to user control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,
I have the following code, without option Strict on, it seems work OK, but
when option strict is on. I have a problem for the assignment.

Dim ctrlarr(5) As PeopleInfo 'poepleinfo is user control in project
Dim i As Integer
If Not Session("ctrlarr") Is Nothing Then
ctrlarr = Session("ctrlarr")
End If
It says option strict on disallows implicit conversion from 'system.object'
to '1-dimensional array of subway.peopleinfo'
I guess I would have the same problem when I assign
Session("ctrlarr")=ctrlarry in the first page if I turn on option Strict.
What should I do in this case?
 
You have to cast to specific type before assiging it back.
In c# it will be ctrlarr = (subway.peopleinfo)Session("ctrlarr")
Not sure what VB cast looks like
 
Hi GS,
I did
ctrlarr = CType(Session("ctrlarr"), PeopleInfo())
It didn't complain anything.
I haven't run the code, guess it's OK.
Thank you.
 
Hi Betty,

I suggest always explicitly cast object to their actual type since that'll
also help improve performance and avoid problem.

If there're any other problem, please feel free to post here.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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

Similar Threads

maintain session array variable 4
sqlstransaction problem 1
How would I fix this error? 2
Option Strict 12
Does Option Strict On add overhead? 2
Error when 'option strict' 2
option strict 5
cast problem 2

Back
Top