Originally Posted by
pmnicaragua
Hello Daniil,
Those are simply objects that store the info from the grids, and the thing is that there is only one huge "Save method" that gets all the info from the 8 tabs, i have to say that all tabs are in the same page, they look just like a wizard form that you guys have on
https://examples2.ext.net/#/Layout/CardLayout/Basic/.
And yeah, that seems to be the problem, values of variables are not mantained, is there a way to overcome this obstacle? Like with Session Variables or ViewState?
Ok, so after reading a lot sessions and viewstate lectures, i ran into the solution, all i had to do was to declare a few session variables after saving my grid into the object, like this:
Session["Grid1"] = ListWithValues1;
Then on the save method, the one that actually has to recover all of the objects previously saved all i had to do is to call my session variable previously created and cast it to the right variable type
PublicVariableList = (PublicVariableList<>)Session["Grid1"];
Actual code goes like this:
In the method that stores into the database:
LEstudioR = (List<EstudioRealizado>)Session["EstudiosRealizados"];
In the method that stores data into the object
protected void SubmitSelectionGrdEstudios(object sender, DirectEventArgs e)
{
string json = e.ExtraParams["Values"];
string TipoEstudio;
string Institucion;
string TipoCertificado;
DateTime FechaInicio;
DateTime FechaFinal;
List<string> resultado = new List<string>();
if (string.IsNullOrEmpty(json))
{
return;
}
foreach (XmlNode row in xml.SelectNodes("records/record"))
{
EstudioRealizado EstudioR = new EstudioRealizado();
TipoEstudio = row.SelectSingleNode("TipoEstudio").InnerXml;
Institucion = row.SelectSingleNode("Institucion").InnerXml;
FechaInicio = Convert.ToDateTime(row.SelectSingleNode("FechaInicial").InnerXml);
FechaFinal = Convert.ToDateTime(row.SelectSingleNode("FechaFinal").InnerXml);
TipoCertificado = row.SelectSingleNode("TipoCertificado").InnerXml;
try
{
EstudioR.TipoEstudio = Convert.ToInt32(TipoEstudio);
EstudioR.TipoCertificado = Convert.ToInt32(TipoCertificado);
EstudioR.Institucion = Institucion;
EstudioR.FechaInicial = FechaInicio;
EstudioR.FechaFinal = FechaFinal;
LEstudioR.Add(EstudioR);
}
catch (FormatException fe)
{
Mensajes.escribirTopRight("Exception", "Warning", Ext.Net.Icon.Information);
}
}
Session["EstudiosRealizados"] = LEstudioR;
}
This way i can preserve my information across server requests, hope this is useful to others with the same problem, mark this as closed please.