Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5845817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:29:20+00:00 2026-05-22T12:29:20+00:00

I am trying to pass data between two pages using Session State in ASP.NET.

  • 0

I am trying to pass data between two pages using Session State in ASP.NET. The data that needs to be passed is from a GridView’s Cell. So, on SelectedIndexChanged event I’m storing the data like that:

protected void GridViewEmployees_SelectedIndexChanged(object sender, EventArgs e)
{
        Session["Name"] =   
           this.GridViewEmployees.Rows[GridViewEmployees.SelectedIndex].DataItem;
}

And then, I want to use the Session’s contents in another page. The code:

protected void Page_Load(object sender, EventArgs e)
{
        string name = (string)(Session["Name"]);
        string[] names = name.Split(' ');
        this.EntityDataSourceNorthwind.Where = 
           "it.[FirstName] = \'" + names[0] + 
           "\' AND it.[lastName] = \'" + names[1] + "\'";
}

But I get a null reference exception. Also, I have set the Session initialization on the Page_Load event and there the Session is stored and everything works just fine. I mean:

protected void Page_Load(object sender, EventArgs e)
{
        if (Session["Name"] == null)
        {
            Session["Name"] = "Andrew Fuller";
        }
}

This is in the page which sends the information.

If you need more source or info, just write it down. It will be provided ASAP.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:29:21+00:00Added an answer on May 22, 2026 at 12:29 pm

    This is actually not a problem with your Session. A row’s DataItem is only available during the RowDataBound event. Set a break point in your GridViewEmployees_SelectedIndexChanged method, and check the value of the DataItem in your immediate window. It will be null.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make an app that will pass data between two servers
I am trying to pass data between two activities that are inside of tabs.
I'm trying to build an ASP.NET MVC 2 application. I want to pass data
I'm trying to pass an instance of a class between two separate classes, like
I'm trying to write a glue function between two data types and I can't
i am trying to pass an array between two functions. The _data function is
I'm trying to pass in a Base64 string into a C#.Net web application via
I'm trying to pass one method to another in elisp, and then have that
I'm trying to pass a complex object (that can be serialized, if that helps)
I am trying to pass a dataString to to an ajax call using JQuery.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.