how to maintain session variable after refresh hit??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vaibhavz
    New Member
    • Feb 2008
    • 1

    how to maintain session variable after refresh hit??

    hi
    i'm having one application in that i'm using one session variable.
    my code works fine till the user hits refresh button but
    after this session variable becomes empty.

    below is the code i'm using

    string RenderedOutput = string.Empty;
    public static int Index = 0;
    DataTable dt = new DataTable();
    DataRow dr;
    DataView dv;

    protected void Page_Load(objec t sender, EventArgs e)
    {
    ClientScriptMan ager scriptMgr = Page.ClientScri pt;
    String ContextID = "__gv" + GridView1.ID.To String() + "__div";
    String cbReference = scriptMgr.GetCa llbackEventRefe rence(this, "arg", "ReceiveServerD ata", ContextID);
    String callbackScript = "function CallServer(arg, context) {"+ ContextID + ".innerHTML = 'Loading...;" + cbReference + ";}";
    scriptMgr.Regis terClientScript Block(this.GetT ype(), "CallServer ", callbackScript, true);

    if (!Page.IsPostBa ck)
    {
    DataColumn dc1 = new DataColumn("Emp Id", typeof(System.I nt32));
    DataColumn dc2 = new DataColumn("Nam e", typeof(System.S tring));
    DataColumn dc3 = new DataColumn("Des ignation", typeof(System.S tring));
    DataColumn dc4 = new DataColumn("Sal ary", typeof(System.I nt32));
    dt.Columns.Add( dc1);
    dt.Columns.Add( dc2);
    dt.Columns.Add( dc3);
    dt.Columns.Add( dc4);
    dt.Constraints. Add("PrimaryEmp ID",dc1, true);
    Session["empTable"] = dt;
    }
    }

    please tell me how to maintain Session["empTable"] even after refresh hit??
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    Try to increase the value for session timeout in web.config file. May be your session is getting expired. Also check that when first time you set the session variable if it is null or not.

    Originally posted by vaibhavz
    hi
    i'm having one application in that i'm using one session variable.
    my code works fine till the user hits refresh button but
    after this session variable becomes empty.

    below is the code i'm using

    string RenderedOutput = string.Empty;
    public static int Index = 0;
    DataTable dt = new DataTable();
    DataRow dr;
    DataView dv;

    protected void Page_Load(objec t sender, EventArgs e)
    {
    ClientScriptMan ager scriptMgr = Page.ClientScri pt;
    String ContextID = "__gv" + GridView1.ID.To String() + "__div";
    String cbReference = scriptMgr.GetCa llbackEventRefe rence(this, "arg", "ReceiveServerD ata", ContextID);
    String callbackScript = "function CallServer(arg, context) {"+ ContextID + ".innerHTML = 'Loading...;" + cbReference + ";}";
    scriptMgr.Regis terClientScript Block(this.GetT ype(), "CallServer ", callbackScript, true);

    if (!Page.IsPostBa ck)
    {
    DataColumn dc1 = new DataColumn("Emp Id", typeof(System.I nt32));
    DataColumn dc2 = new DataColumn("Nam e", typeof(System.S tring));
    DataColumn dc3 = new DataColumn("Des ignation", typeof(System.S tring));
    DataColumn dc4 = new DataColumn("Sal ary", typeof(System.I nt32));
    dt.Columns.Add( dc1);
    dt.Columns.Add( dc2);
    dt.Columns.Add( dc3);
    dt.Columns.Add( dc4);
    dt.Constraints. Add("PrimaryEmp ID",dc1, true);
    Session["empTable"] = dt;
    }
    }

    please tell me how to maintain Session["empTable"] even after refresh hit??

    Comment

    Working...