[CLOSED] Help saving values from GridPanel

  1. #1

    [CLOSED] Help saving values from GridPanel

    Last edited by Baidaly; Oct 28, 2013 at 6:18 PM. Reason: [CLOSED]
  2. #2
    Hi @pmnicaragua,

    Are these properties just the Page's ones?
    public List<EstudioRealizado> LEstudioR;
    public List<OtroEstudio> LOtroEst;
    How do you save it to a database? In an individual request?

    One request - SubmitSelectionGrdEstudios - for saving data to those Page's variables, another request - to save it to database?

    If so, I think the problem is the fact that the Page's variable are not maintained across requests. This example demonstrates it.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        public string TestProp;
    
        protected void Set(object sender, DirectEventArgs e)
        {
            this.TestProp = "Hello!";
        }
        
        protected void Get(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("", this.TestProp).Show();
        }
    </script>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:Button runat="server" Text="Set" OnDirectClick="Set" />
    
            <ext:Button runat="server" Text="Get" OnDirectClick="Get" />
        </form>
    </body>
    </html>
    It might be best to save the data from the Store to the database in the single request.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @pmnicaragua,

    Are these properties just the Page's ones?
    public List<EstudioRealizado> LEstudioR;
    public List<OtroEstudio> LOtroEst;
    How do you save it to a database? In an individual request?

    One request - SubmitSelectionGrdEstudios - for saving data to those Page's variables, another request - to save it to database?

    If so, I think the problem is the fact that the Page's variable are not maintained across requests. This example demonstrates it.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        public string TestProp;
    
        protected void Set(object sender, DirectEventArgs e)
        {
            this.TestProp = "Hello!";
        }
        
        protected void Get(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("", this.TestProp).Show();
        }
    </script>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:Button runat="server" Text="Set" OnDirectClick="Set" />
    
            <ext:Button runat="server" Text="Get" OnDirectClick="Get" />
        </form>
    </body>
    </html>
    It might be best to save the data from the Store to the database in the single request.
    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?
  4. #4
    Quote Originally Posted by pmnicaragua View Post
    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.
  5. #5
    Yes, the Session object can be used to store the data across the different requests. But please note that the Session uses cookies (by default). Do you need all that data in the cookies? Do you really need that intermediary store? Well, if you have to make different requests for each Store/GridPanel to save its data then there is no principal alternative. But are you really restricted to save it in different requests?

    As far as I can understand your scenario it is:

    1. Wizard step #1
    2. A user fill out a GridPanel and goes to the Wizard step #2
    3. Here you save the data filled out on the step #1
    4. Wizard step #2
    5. A user fill out a GridPanel and goes to the Wizard step #3
    6. Here you save the data filled out on the step #2
    7. etc.

    Has I got it right? If yes, then is there any chance to save all the data at the final step? It should be possible if, as you said, all the GridPanels are on the same page.

    Or, maybe, you would like not to lose the data filled out in the previous Wizard steps if something crashes? Well, yes, it makes sense.
  6. #6
    The thread looks related to this one:
    http://forums.ext.net/showthread.php?27004

Similar Threads

  1. Replies: 2
    Last Post: Sep 02, 2013, 6:49 PM
  2. MVC Gridpanel Saving Help
    By ChrisB in forum 2.x Help
    Replies: 0
    Last Post: Aug 14, 2012, 4:18 PM
  3. saving dynamically-created controls' values
    By Skizzot223 in forum 1.x Help
    Replies: 1
    Last Post: Apr 16, 2012, 12:54 PM
  4. Replies: 2
    Last Post: Apr 14, 2011, 9:03 AM
  5. [CLOSED] Getting row changes from GridPanel when saving
    By egodoy in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 29, 2009, 2:34 PM

Tags for this Thread

Posting Permissions