Session Variables and Visual Studio
Session variables are useful for storing data throughout the user's session, ie until they logout, or close the browser, or get timed out (usually after 20 minutes with no activity). Your session variable values are not accessible by other users.
One useful session variable is to store the logged-in UserName, which can be accessed from the system. This could be set in the code-behind page that users land on when they login, or in the MasterPage.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Session("UserName") = System.Web.HttpContext.Current.User.Identity.Name
This value can then be used to identify every record created by the user, and to read back just the user's own records. This is an essential requirement for personalisation of a web site or intranet.
Next, we need a table to store personal data. This is best done within the ASNetDB.mdb database so it can link to the built-in aspnet_Users table, with a matching UserName value for each user. Do not enforce referential integrity at this stage - that can be imposed once the system is set up to create the user profile entry automatically when a new user account is created.
We now need to add a page so users can edit their profile.
Add a MyProfile.aspx page to the Users folder (that is restricted to just authenticated users) and add a DetailsView that uses the UserProfile table and a WHERE selection to get just the user's own record.
Test the query with a parameter value (eg Ray)
Enable editing of the DetailsView and edit the field for UserName to make it Read-only and remove references to updating the UserName form the Update command for the DataSource properties
Then view in browser
Update the web.sitemap, and login as a different user. Check you can edit their profile, but not their username.
Create an AllProfiles.aspx page in the Admin folder, and add a GridView to view all the user profiles, with paging, sorting, editing and deleting and update the web.sitemap appropriately.
Make sure the username cannot be edited. Now format the datagrid, and make sure every page has a title.
Now we need a list of Users without a profile. Create a page called UsersWithoutProfiles.aspx and add a datagrid based on this query which uses a left outer join
Create some extra users, then view in browser
Now we need a way to add a record for each of these. This is left as an exercise to the reader.