Session array
-
Hi all, somebody knows how create a array multi-dimensional with session variables. I have it:
Session("Preguntas") = LPH.ObtenerTest(Session("Articulo"), Session("Nivel"))
where it session is a table and I want to add the result of client into other session array but with 2 columns, something similar to
Session("ArrayRespuestas")(Session("i"), 1) = "1"
. I use session variable because when the user make click into button I receive a postback and lost my original select (LPH.ObtenerTest(Session("Articulo"), Session("Nivel"))) that is a procedure that return a select random with 2 parameters. If I use
If Not Me.Page.IsPostBack Then
and put my select into later (the second page_load) doesn't load my select and when I call to
Preguntas.Rows(i)("Respuesta1")
I received a error where told me that I must first create a object. Thanks for all.
-
Hi all, somebody knows how create a array multi-dimensional with session variables. I have it:
Session("Preguntas") = LPH.ObtenerTest(Session("Articulo"), Session("Nivel"))
where it session is a table and I want to add the result of client into other session array but with 2 columns, something similar to
Session("ArrayRespuestas")(Session("i"), 1) = "1"
. I use session variable because when the user make click into button I receive a postback and lost my original select (LPH.ObtenerTest(Session("Articulo"), Session("Nivel"))) that is a procedure that return a select random with 2 parameters. If I use
If Not Me.Page.IsPostBack Then
and put my select into later (the second page_load) doesn't load my select and when I call to
Preguntas.Rows(i)("Respuesta1")
I received a error where told me that I must first create a object. Thanks for all.
The below code allows a multi-dimensional array to be stored in the session state. See if you can adapt this to fit your use. Good luck.
private void StoreToSession()
{
string[,]initialArray={"A","B"};
Session["sessionvalue"]=initialArray;
}private void ReteriveFromSession()
{
string[,]resultantArray=(string[,])Session["sessionvalue"];
TextBox1.Text=resultantArray[0,0].ToString();
TextBox2.Text=resultantArray[0,1].ToString();
}Ranjit Viswakumar Professional Services Specialist http://hostmysite.com/?utm\_source=bb
-
The below code allows a multi-dimensional array to be stored in the session state. See if you can adapt this to fit your use. Good luck.
private void StoreToSession()
{
string[,]initialArray={"A","B"};
Session["sessionvalue"]=initialArray;
}private void ReteriveFromSession()
{
string[,]resultantArray=(string[,])Session["sessionvalue"];
TextBox1.Text=resultantArray[0,0].ToString();
TextBox2.Text=resultantArray[0,1].ToString();
}Ranjit Viswakumar Professional Services Specialist http://hostmysite.com/?utm\_source=bb
Doesn't work because the postback empty my array when I push btton. I have when load the first ask (is a test of 25 ask):
Public Ar1(25, 1) As Integer
Procedure of load ask
Ar1(Session("i"), 0) = Session("Preguntas").Rows(Session("i"))("Id\_Pregunta") Session("ArrayRespuestas") = Ar1
later when button_onclick:
Dim respuesta As Integer
If RadioButton1.Checked = True Then respuesta = 1
If RadioButton2.Checked = True Then respuesta = 2
If RadioButton3.Checked = True Then respuesta = 3
If RadioButton4.Checked = True Then respuesta = 4
If RadioButton5.Checked = True Then respuesta = 5
Ar1(Session("i"), 1) = respuesta
Session("ArrayRespuestas") = Ar1
Session("i") = Session("i") + 1This work without errors, but when I try to recovery the datas of array I only get the value present Ar1(Session("i"), 1) but I lost the value Ar1(Session("i"), 0) because was added before of push button and later the postback empty my array. Good, realty is when I put Session("ArrayRespuestas") = Ar1 is when I clear my session array. I believe that the solve is to search like get not postback when click button. I accept advisers boys :)
-
Doesn't work because the postback empty my array when I push btton. I have when load the first ask (is a test of 25 ask):
Public Ar1(25, 1) As Integer
Procedure of load ask
Ar1(Session("i"), 0) = Session("Preguntas").Rows(Session("i"))("Id\_Pregunta") Session("ArrayRespuestas") = Ar1
later when button_onclick:
Dim respuesta As Integer
If RadioButton1.Checked = True Then respuesta = 1
If RadioButton2.Checked = True Then respuesta = 2
If RadioButton3.Checked = True Then respuesta = 3
If RadioButton4.Checked = True Then respuesta = 4
If RadioButton5.Checked = True Then respuesta = 5
Ar1(Session("i"), 1) = respuesta
Session("ArrayRespuestas") = Ar1
Session("i") = Session("i") + 1This work without errors, but when I try to recovery the datas of array I only get the value present Ar1(Session("i"), 1) but I lost the value Ar1(Session("i"), 0) because was added before of push button and later the postback empty my array. Good, realty is when I put Session("ArrayRespuestas") = Ar1 is when I clear my session array. I believe that the solve is to search like get not postback when click button. I accept advisers boys :)