ASP.NET 2.0 How-To: Bind datasource parameter to UserID?

  • Thread starter Thread starter Luke Dalessandro
  • Start date Start date
L

Luke Dalessandro

I am trying to develop a quick Shopping cart for ASP.NET 2.0. I have added a
CartItems table to the AspNetDB access database, that contaings CartItems
keyed off of the aspney_Users.UserId key (the automatically generated
primary key for the table).

I want to bind the current user's CartItems to a GridView, which should be
really easy. The problem is that I need the UserID as a parameter for my
AccessDataSource. The parameters that can be automatically accessed can come
from any of the:

Control
QueryString
Session
Cookie
Form
Profile

groups.

I can't seem to find UserId exposed anywhere. The profile exposes UserName,
which I use to programatically grab the UserId for logged in users, but the
Cart needs to work for anonymous users...

Any help would be appreciated. I don't really want to write an
ObjectDataSource, although I will if that is the only way. It seems like
there should be some way to automatically bind to UserId though.
 
Look at the help file for "Understanding ASP.NET Profile Properties". You can
add any properties you want. That is where I would start.

---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
Thanks Cowboy,

This sort-of helps.

I know how to add properties and interact with the Profile object, and to
enable anonymous users.

I also know that I can write Profile values in the Application
OnAcquireRequestState event.

I guess that what I don't know how to do is to access the ASP.NET-assigned
UserID for an anonymous user.

Luke
 
Back
Top