V
Vince13 via DotNetMonster.com
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 = new cut(((cut[])Session["allCuts"]));
//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.
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 = new cut(((cut[])Session["allCuts"]));
//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.