Written by: Matthew Hile 3/1/2006 7:13 AM
To save/consume a multidimensional array to a session variable in .NET you use the following steps.Store the arrayCreate the arrayDim aToSave(0, 1) As Integer ' a 10x2 array' Populate the array with valuesSave it to a session variableSession("aToSave") = aToSaveRestore the arrayCreate an array to hold the saved valueDim aToSave(0, 1) As Integer ' a 10x2 arrayConvert the saved variable to the appropriate type and assigne itaToSave= CType(Session("aToSave"), Integer(,))It was this last step the threw me. The "Integer(,)" converts the session variable to an interger array with two dimensions. If it were a two dimensional character array you would use "Char(,)"
Dim aToSave(0, 1) As Integer ' a 10x2 array' Populate the array with values
Save it to a session variable
Session("aToSave") = aToSave
Dim aToSave(0, 1) As Integer ' a 10x2 array
aToSave= CType(Session("aToSave"), Integer(,))
0 comments so far...