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

national_fulfillmentAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.