how to assign session object to user control

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?
 
G

GS

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
 
G

Guest

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.
 
S

Steven Cheng[MSFT]

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

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top