Drenriza
December 4th, 2011, 01:02 PM
Hi all.
I am working on a ASP.NET site, where i have some trouble with some of my get and set methodes.
I currently have 3 classes, to seperate the different methodes and to give a good overview.
In my WebForm1.aspx.cs class i add my values to my get and set
foreach (String[] line in tableListTwo)
{
getAndSet.CellOne = line[0];
getAndSet.CellTwo = line[1];
getAndSet.CellThree = line[2];
getAndSet.CellFour = line[3];
getAndSet.CellFive = line[4];
getAndSet.CellSix = line[5];
getAndSet.CellSeven = line[6];
getAndSet.CellEight = line[7];
getAndSet.CellNine = line[8];
getAndSet.CellTeen = line[9];
And the values get added to the get and set, no trouble so far.
publicString _CellOne = "Removed";
publicString _CellTwo = "Removed";
publicString _CellThree = "Removed";
publicString _CellFour = "Removed";
publicString _CellFive = "Removed";
publicString _CellSix = "Removed";
publicString _CellSeven = "Removed";
publicString _CellEight = "Removed";
publicString _CellNine = "Removed";
publicString _CellTeen = "Removed";
The problem is when i call for the values. Then i don't get the value that i've added to the get and set. I get the static value "Removed"
For example i add the value 2, to _CellOne, but i retrive the value Removed.
cell1.Text = getAndSet.CellOne;
cell2.Text = getAndSet.CellTwo;
cell3.Text = getAndSet.CellThree;
cell4.Text = getAndSet.CellFour;
cell5.Text = getAndSet.CellFive;
cell6.Text = getAndSet.CellSix;
cell7.Text = getAndSet.CellSeven;
cell8.Text = getAndSet.CellEight;
cell9.Text = getAndSet.CellNine;
cell10.Text = getAndSet.CellTeen;
Is this because i need to use a viewstate to save the values in? For some reason they get lost when retrived them into a different class then the WebForm1.aspx.cs class.
Hope you understand what i mean. I am not a C# shark ,) im quite new at it.
If their is something that sounds fuzzy, please dont hesitate to ask and i will try to elaborate.
Thanks all on advance.
Kind regards.
Edit.
is their someone who can explain to me when to use a viewstate and when to use a get and set methode?
Edit 2.
Well i have read a little up on what a viewstate is. So my question is more focused on. When i from my page.aspx.cs file, add a value to a get&set methode in a C# class. And then call that same value to another C# class, why do i then "loose" the value. Resulting in getting the static value, when i defined the get&set methode. And how can i prevent "loosing" the value?
I am working on a ASP.NET site, where i have some trouble with some of my get and set methodes.
I currently have 3 classes, to seperate the different methodes and to give a good overview.
In my WebForm1.aspx.cs class i add my values to my get and set
foreach (String[] line in tableListTwo)
{
getAndSet.CellOne = line[0];
getAndSet.CellTwo = line[1];
getAndSet.CellThree = line[2];
getAndSet.CellFour = line[3];
getAndSet.CellFive = line[4];
getAndSet.CellSix = line[5];
getAndSet.CellSeven = line[6];
getAndSet.CellEight = line[7];
getAndSet.CellNine = line[8];
getAndSet.CellTeen = line[9];
And the values get added to the get and set, no trouble so far.
publicString _CellOne = "Removed";
publicString _CellTwo = "Removed";
publicString _CellThree = "Removed";
publicString _CellFour = "Removed";
publicString _CellFive = "Removed";
publicString _CellSix = "Removed";
publicString _CellSeven = "Removed";
publicString _CellEight = "Removed";
publicString _CellNine = "Removed";
publicString _CellTeen = "Removed";
The problem is when i call for the values. Then i don't get the value that i've added to the get and set. I get the static value "Removed"
For example i add the value 2, to _CellOne, but i retrive the value Removed.
cell1.Text = getAndSet.CellOne;
cell2.Text = getAndSet.CellTwo;
cell3.Text = getAndSet.CellThree;
cell4.Text = getAndSet.CellFour;
cell5.Text = getAndSet.CellFive;
cell6.Text = getAndSet.CellSix;
cell7.Text = getAndSet.CellSeven;
cell8.Text = getAndSet.CellEight;
cell9.Text = getAndSet.CellNine;
cell10.Text = getAndSet.CellTeen;
Is this because i need to use a viewstate to save the values in? For some reason they get lost when retrived them into a different class then the WebForm1.aspx.cs class.
Hope you understand what i mean. I am not a C# shark ,) im quite new at it.
If their is something that sounds fuzzy, please dont hesitate to ask and i will try to elaborate.
Thanks all on advance.
Kind regards.
Edit.
is their someone who can explain to me when to use a viewstate and when to use a get and set methode?
Edit 2.
Well i have read a little up on what a viewstate is. So my question is more focused on. When i from my page.aspx.cs file, add a value to a get&set methode in a C# class. And then call that same value to another C# class, why do i then "loose" the value. Resulting in getting the static value, when i defined the get&set methode. And how can i prevent "loosing" the value?