Display data for logged in User only

I try to figure out how to display data which belongs to one individual User only.

Once the User logged in, he should see only the data which is related to his UserId. Currently I'm using

SELECT aspnet_Customers.FirstName, aspnet_Customers.LastName, aspnet_Customers.Address, aspnet_Customers.ZipCode, aspnet_Customers.City, aspnet_Customers.Country, aspnet_Customers.CustomerID, aspnet_Customers.UserID, aspnet_Membership.LoweredEmail, aspnet_Membership.LastLoginDate FROM aspnet_Customers INNER JOIN aspnet_Membership ON aspnet_Customers.UserID = aspnet_Membership.UserId

Two Questions:

1. What I need to do in Order to display only data for the user which is logged in without the ability to edit / update / delete data

 2. The Admin will login using the same login page. When he login, he should see the data from all users and he should be able to edit / update / delete them

 I learned already that I need to use

aspnet_Membership.UserId = @UserId

This @UserId parameter value will be System.Web.HttpContext.Current.User.Identity.Name

however, how do I include that, how the query should look like and how can I specify in the query that the Admin should not use this Filter?



7/9/2008 9:29:55 AM
asp.net.getting-started 91979 articles. 3 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 39

Does really nobody know who this should be done?


7/9/2008 11:57:28 PM


use a where clause

where (@UserId == User.Identity.Name)

Please remember to click “Mark as Answer” on the post that helps you
7/10/2008 7:49:11 AM

Yes, but how do I specify that some Users like Admins can see everything?


7/10/2008 9:45:49 AM

so many ways

you can create an admin page. write a new query (select * from...) and then don't allow other users to see admin page

you can use Linq to sql if you use .net 3.5 .it is so simple and felexible. you can have an if in code behind which checks if User.Identity.Name == Admin or not . then define 1 query for then clause and 1 query for else clause

let me know if you want more solutions  

Please remember to click “Mark as Answer” on the post that helps you
7/10/2008 10:41:35 AM

Similar Artilces:

how to get user data from a logged in user
I have the standard login controls from ASP.NET 2.0 on my site. Now i've added a id field from another table to the aspnet_users table as FK. Now i want to use this ID (if the user is logged in) to populate my datagrid. How can i get this ID?  Erik    Check below link Work With Membership API HCHaissam Abdul MalakMCAD.NET| Blog | Hi Please follow the link http://forums.asp.net/thread/1702250.aspx and raise the problem you've meet :) Good luckBest RegardsXiaoYong DaiMicrosoft Online Community SupportPlease remember to click “Mark as Answer” on the ...

Logged in user displays user specific data from database
Hi there - I am fairly new to ASP.NET and am hoping for some guidance here ... I am building an application for manages to track employees as the employee leaves the business.  Basically there are processes a line manager is required to complete and I want the manager to enter completion dates when those processes have been completed. I have gotten as far as successfully creating the login/membership controls.  The user (line manager) logs in and is then redirected to the correct page and thats fine.  However, I then want for the user to see records from a dat...

display data for a particular logged in user (User.Identity.Name;)
hi, basically i have a database table with: fileNo, fileName, fileSize, fileType, fileOwner etc at the minute my grid view displays ALL files for every fileOwner, how does one filter this to only displaying the files which belong to a particular fileOwner who is logged in.. i.e. SELECT * FROM tblFile       WHERE fileOwner = (User.Identity.Name)         -   to show files for a user who is logged in   how does one do this please?   thanks and regards Hi,jules U can Do like thisI am assuming that ur ...

How do I display data in a datagrid specific to the logged in user using the User ID
Hi, I've got a table that holds user details (such as age, location etc). This table is linked to a user logon details table by the UserID column. How do I get a datagrid to display the logged on users details?  Everything I've read so far uses Username but username isn't a column in my UserDetails table. I've tried SELECT all from the user details table and using UserID as a session parameter but the datagrid doesn't display so I'm doing something very wrong I think. The sql statement looks like this:  SELECT UserID, FirstName, Surname, Telephone, Sect...

Session problem(Previous Users log-in details are getting displayed/withheld for the current user)
Hi we've hosted Bugzilla in windows 2000 server & it has been used by many users at a given time.we've been getting this peculiar Session problem.ie.If a user logs-in, the page that he visits contains the details of another user who has just signed out from bugzilla.Any & all suggestions are welcome. Regards Tamil ...

Display data for Logged in user
 Hi, I am trying to show data from a database where one of the DB field values matches the name of the logged in user. I have LoginName control on the same page so I only want to display data that has a matching value in the DB field.Hope that makes sense? Thanks Here is what you can do: Dim uname as String = user.identity.name if user.identity.isauthenticated then sqlcmd="SELECT * from db_base Where username='" & uname & "' " then execute the sqlcmd that is itFun begins at http://www.ovbet.comNow...From the first humanplace &n...

How do I get profile data before user logs in?
I have a login control. There's profile information containing a date for when the account will expire. I want to check this every time the user tries to login. Currently I am using the Authenticate in which does not give me access the profile data because the user isn't yet logged in.  How do I go about doing this task?  What events, if any, should I override? BTW, I am using a standard membership provider so I can't perform queries.  Thanks in advance.  Try this Profile.GetUser(username).ExpiryDate CheersRegardsRamzi-------------------------------------------...

Displaying current logged in user data
 Hey I been struggling for 3 days on something that just seems so weird ,..why it can be so difficult to achieve????in aspnet_Membership datatable,  there's a datafield UserIdI have link that UserId with my datatable called CompanyDetails which also have a UserId..(this is the foreign key) so what  Im trying to do is If i know the current user's UserId from the aspnet_Membership datatablethen I will be able to pull his/her datarow from the CompanyDetails database...as simple as thatso I have tried this with my following code...but Sqldatasource does not want to filter ...

Displaying data (formview) only to logged in users
 Hi ! I'm trying to display data via a formview only to logged in users. I haven't figured how to do that yet using the session parameter of the objectdatasource. Could anyone help ?Thanks !  Top of the page, clcik the Learn link. JeffPlease: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue. how stupid is that answser. Don't bother replying for this kind of nonsense. zedisnotyetdead: I'm trying to display data via a formview only to logged in users. I hav...

How to get data from data base and display it in data grid
 hi,am having a connection to data base and now what i want is , how can i display the data from database and display it in my data grid.any sample code of 2 or 3 lines can be of great help. i know how do i get data for a drop down from data base  as below.List<CRoleBE> roleList = roleInterface.GetAllRoles();ddlBaseRole.Items.Add(new ListItem("Select any Role", "-1"));foreach (CRoleBE businessEntity in roleList){    ListItem item = new ListItem(businessEntity.Name, businessEntity.ID.ToString());    ddlBaseRole.Items.Add(i...

Display data in a datagrid that is specific to only the logged in user
How do you display data from tables that is based on the logged in username.  I know that some post are saying to use the "GetUser" method via Membership.  Like for example, I want to display all vendor information for a specific vendor that has logged onto the application in a datagrid?  The username in the database is the same as the VendorID.  I'm using Visual Studio 2005 and a SQL Server 2005 database.   Any feedback would be greatly appreciated. Thanks, rsandes2 (Still a newbie) Hi, If your users are logging into website and the login name m...

display data from database accordingly when users log in
  the situation is after someone loggs in with his credentials then on his page he should be displayed data relating only to his pageand so and if someone else loggs in on his page his data from the database such as sql server 2005 should be displayedplease helo out if anyone know how to do this in asp,net c# Hi,aditya Try This Example In sql CReate table register (id int identity ,[UserName] varchar(20),[Password] varchar(20), varchar(30)) GO insert into register Select 'User1','Pass1','Email1' union all Select 'User2','Pass2',...

problem in displaying data corresponding to currently logged in user
i am using visual studio 2005 with SQL Express 2005 with VB as the code behindi am using the inbuilt membership and roles to create users and access permissions i am using a formview to display data from a databasedata in formview is displayed corresponding to a parameter passed to iti want that parameter to be the curently logged in username (user.identity.name)how to pass this parameter and where to pass it ?please help me  Hi, if you're using a DataSource control to bind the FormView control with you can inject the username in the Selecting event. Grz, KrisRead my blog. Hand...

Web resources about - Display data for logged in User only - asp.net.getting-started

Comparison of display technology - Wikipedia, the free encyclopedia
CRTs use an electron beam, scanning the display, flashing a lit image. If interlacing is used, a single full-resolution image results in two ...

The Christmas light display at Bissenberger crescent Kambah.
Photographer Melissa Adams visited Kambah's famous Bissenberger crescent and it's popular Christmas light display.

The Christmas light display at Bissenberger crescent Kambah.
Photographer Melissa Adams visited Kambah's famous Bissenberger crescent and it's popular Christmas light display.

Display Advertising Is Hard to Quit
BuzzFeed has made waves in the worlds of media and advertising by eschewing display ads in favor of branded content created specifically for ...

On Display: Germaine Greer’s Life Magazine Outtakes
It’s a long way – in years and miles – from the cover of Life magazine in 1971 to the display spaces of the Ian Potter Museum of Art in Melbourne ...

Secular nativity display removed from Texas capitol after complaint from Governor Abbott
A secular “winter solstice” display has been removed from the Texas capitol basement following a complaint from Governor Greg Abbott, who in ...

Genius now displays song lyrics no matter what music app you use
Shutterstock Genius has unleashed an update that will give you live lyrics to whatever song you’re listening to. What’s particularly brilliant ...

Apple's secret display lab might be making holographic iPhone screens unlike anything we've seen before ...
... potential explanations for Apple’s new research facility . After Bloomberg explained that as many as 50 employees are working on new display ...

Insta-Graham: With postseason on the line, Buffalo's display just sickening
Dysentery couldn't have run through the Buffalo Bills any faster than Washington did. Bills defensive end Mario Williams stayed home sick earlier ...

A Florida couple is being sued over their insane Christmas display
The Hyatt family of Plantation, Florida, spends months decorating their home for Christmas. They put together an insanely elaborate display that ...

Resources last updated: 12/24/2015 4:17:38 AM