tags:

views:

331

answers:

2

Hi,

I have a web application which has a Sql Server database on the backend. As the site will be rolled out to different clients (or different virtual directories in IIS), each client derivative of the site will use the same backend.

There is an admin page where text on the site can be changed (enter text in a listview, and choose the page to select where that text will show up, and also you can see company-specific details in the other listviews. As this is a shared database, that means a client can see each other's data.

What I am trying to do is store the accountId (a guid returned from the database from login_authenticate), and stick this into session. I then retrieve this on the admin page, and I want to use this value (But it's always 0000-0000 etc), to limit the records returned in the listview.

Is there an example of this? Also, how can I set the default value (this is in the where clause of SqlDataSource), to programatically what the account id is (so I can give me all records = what the current accountid is, or perhaps, what the login is - this is stored in the account table).

Thanks

A: 

It sounds like your method should be working. I would follow a debugging process:

  1. Check that you are getting the accountID value from the database. Print it on screen immediately after retrieving the value for the first time.
  2. If this is working, store the value in the Session and immediately retrieve it, and check that you are getting the value back.
  3. Create 2 test pages, one where you set the Session variable and another where you retrieve it.

I know this seems really basic, but the failure is being introduced somewhere in the above 3 places. If you can find which step fails, you will be able to fix it.

Bork Blatt
A: 

This is what I tried.

What I am confused about, though, is whether the where clause, when using a session object, is getting an object that I have written the code to retrieve from the session, or an object I have only added but not retrieved. I get the accountID when logging in (verified via stepping in - obviously - or the login will fail).

I will try again with storing the object in session @ the login page when I have just retrieved the accountid variable, and then retrieve it on another page.

For some reason I keep getting 0s so I will look at this in my application.

dotnetdev