Re: Session variables and reference

Tech-Archive recommends: Fix windows errors by optimizing your registry



If you are going the session route, I find it easier to store ina data
format, like a DataSet. This is not applicable for all.

If you are using a single page for the info, consider ViewState instead. You
are still better to control your own destiny, of course.

I have never had problems with objects in Session, but I am not extensive in
my use of Session either, as I can normally find a better way for my
applications.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************
"Vince13 via DotNetMonster.com" <u35350@uwe> wrote in message
news:75692e15875a8@xxxxxx
I am trying to set up a page where the user can change data, and then click
cancel and the data will not be saved. Currently, I am saving the data in
a
Session variable that is an array of a class I created:

public class cut
{
public cut()
{
ParallelDim = 'G';
cutPoint = ++numCuts;
Knom = 0;
Kmin = 0;
Kmax = 0;
//numCuts++;
}


public cut(cut myCut) //copy constructor
//**note, does NOT increment numCuts
{
ParallelDim = myCut.ParallelDim;
cutPoint = myCut.cutPoint;
Knom = myCut.Knom;
Kmin = myCut.Kmin;
Kmax = myCut.Kmax;
}

public char ParallelDim;
public int cutPoint;
public decimal Knom;
public decimal Kmin;
public decimal Kmax;
public static int numCuts = 0;
}

I realized that when I set my temporary array to equal the session array,
it
was passing the values by reference, so I created new objects using a copy
constructor:

for(int i = 0; i < 20; ++i) //uses copy constructor to initiate myCuts and
make copy so the
{ //changes are not made to Session[allcuts]
myCuts[i] = new cut(((cut[])Session["allCuts"])[i]);
//uses copy constructor to make
identical array
}

This works in that it does create a new array that is not just a reference
to
the old one, but for some reason I cannot write the data back to the
session
array. I am fairly sure it should just work like this:

Session["allCuts"] = myCuts;

but I have also tried using the copy constructor again (reverse of above)
and
setting each individual value of the class separately. Nothing will write
the data back to the session array.

If ANYONE has any ideas, I would greatly appriciate it.

--
Message posted via http://www.dotnetmonster.com



.



Relevant Pages

  • RE: Session variables and reference
    ... Session variable that is an array of a class I created: ... public cut//copy constructor ... Kmax = myCut.Kmax; ... I realized that when I set my temporary array to equal the session array, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: 2 dimension arrays
    ... > How do I declare an array as a session variable? ... as you have a *reference* to this array, there is really only one array ... >> Andrew wrote: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: help with array within another array
    ... you could make a hash with reference to hash values: ... it seems like you might want to consider using the node identifier as the first key in %SESSION, and make the value a reference to hash keyed by the owner and severity: ... I am trying to declare two associative array ...
    (perl.beginners)
  • Re: [PHP] SESSION problem
    ... But, if you came from a background that predated associate arrays, then using numeric indexes would seem more natural. ... looked into the session extension in that level of detail, but I doubt such a limitation would exist if there was not a very good reason for it. ... Given that I can't see into the future, even if I currently only have one set of data to store in the session I wouldn't just chuck the bits of paper from the file into the filing cabinet. ... The root level of the session array should contain descriptive keys, and I've never been in a situation where 5318008 is descriptive and gives context to the data unless you turn it upside down! ...
    (php.general)
  • Re: Using The Same Page To Display A Hundred Pictures One Picture At A Time
    ... >> a temporary cache of the array quite easily. ... As far as I can tell session variables are just little text files ... That way the script can just load it from ... there even for the first load per session. ...
    (comp.lang.php)