[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 713
  • Last Modified:

Strings passed to Session null but works on Debug ASP.NET C#

I pass a few strings to the next page using the Session.Add and when I debug the page the values are there; when i just open in the browser the values are null. Anybody have a clue why?
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string username = (string)(Session["username"]);
        Session.Add("username", username);
              
        int index = GridView1.SelectedIndex;
        DataKey data = GridView1.DataKeys[index];
        string uid = data.Values["UniqueId"].ToString();             GridViewRow row = GridView1.SelectedRow;
        string pendingE = row.Cells[9].Text;
        string comment= row.Cells[6].Text;
 
        Session.Add("username", username);
        Session.Add("uid", uid);
        Session.Add("pendingE", pendingE);
        Session.Add("comment", comment);
        Response.Redirect("VREmail.aspx");         
    }
 
//this is how I snag it on the next page
string uid = (string)(Session["uid"]);

Open in new window

0
national_fulfillment
Asked:
national_fulfillment
  • 3
  • 2
3 Solutions
 
kaylanreilorCommented:
How is Session initialized and what is the OS.
0
 
national_fulfillmentAuthor Commented:
Windows 2003 and I don't initialize so maybe that's my problem.
0
 
national_fulfillmentAuthor Commented:
i initalized them during a change of selection on a grid.
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string username = (string)(Session["username"]);
        Session.Add("username", username);
              
        int index = GridView1.SelectedIndex;
        DataKey data = GridView1.DataKeys[index];
        string uid = data.Values["UniqueId"].ToString();  // needs to be int
        GridViewRow row = GridView1.SelectedRow;
        string pendingE = row.Cells[9].Text;
        string comment= row.Cells[6].Text;
 
        Session["uid"] = uid;
 
        Session.Add("username", username);
        Session.Add("uid", uid);
        Session.Add("pendingE", pendingE);
        Session.Add("comment", comment);
        Response.Redirect("VREmail.aspx");         
    }

Open in new window

0
 
kaylanreilorCommented:
I'm sure to understand what's you're trying to do when writing this :
string username = (string)(Session["username"]);
followed by this :
Session.Add("username", username);

But anyuway, I don't know either what is the goal of your application but would you mind having a look to this article :
http://www.developer.com/db/article.php/10920_3595766_2
And then tell me your thought about it... especially let's check what the guy does in "GridView1_SelectedIndexChanged" !
0
 
national_fulfillmentAuthor Commented:
I changed my app to store the session variables in SQL and it's working without any problems now.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now