Results 1 to 2 of 2

Thread: Session Variables Problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2001
    Posts
    153

    Session Variables Problem

    Hi guys,

    The code in one my aspx files is as follows.

    string sString;
    sString= Session["sfetchline"].ToString();

    void Page_Load(object sender, EventArgs e)
    {

    if (!Page.IsPostBack)
    {
    BindGrid();
    }
    }

    When this page is called. I get the error as follows(line 24)

    System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    Line 23: string sString;
    [B] Line 24: sString= Session["sfetchline"].ToString(); [B]
    Line 25:
    Line 26: if (!Page.IsPostBack)


    I am using the same method to retrieve data from Session variables in other pages as well. But I dont get any errors.
    there r no alternatives 4 hardwork.

  2. #2
    Hyperactive Member vbud's Avatar
    Join Date
    Jan 2002
    Location
    Mru 20 17S, 57 33E Goal: Get out of the BOX Status: In The Shadows!!! Target Posts: 3,000,000,000
    Posts
    378
    Your session variable Session["sfetchline"].ToString is probably not initialised at this moment. Maybe you would want to test if it's not Nothing before retrieving its value. The Session object has an item collection I think, so maybe it might be good to add a new session item "sfetchline" using the method Add and then initialise it to "" by default.
    >!v!<
    Free your mind, stop thinking
    http://inspirone.blogspot.com

    Please rate this post if it helped you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width