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

I know there is something missing or maybe not correct at all.Stick out tongue

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

Anyone here to help me out?

 

 

0
benjaminbkk
7/7/2008 3:08:15 AM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

4 Replies
1891 Views

Similar Articles

[PageSpeed] 21

1) Include and AND clause in your query to filter data only for the logged in user like,

aspnet_Membership.UserId = @UserId

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

2) For the Administrator, do not include any filter so that all the data related to all the users will be retrieved.

3) Diplaying a page in editable or read-only fashion depends on the controls that you use and the way you program. May be use can use a gridview to all the data in a tabular format. And if the current user is "Admin", provide the "Edit" button in the grid (for each row - this can be done with ease) and take him to the details page for editing the selected record. On the other hand, if the current user is NOT an "Admin", do not display the Edit button.

The below link will help you further.

http://msdn.microsoft.com/en-us/library/ms972948.aspx


 

 

 

0
santa_1975
7/7/2008 3:44:53 AM

user User.Identity.Name to get the user name of the currently logged in user


Vikram
www.vikramlakhotia.com


Please mark the answer if it helped you
0
vik20000in
7/7/2008 3:46:04 AM

Sorry, but 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?

 

0
benjaminbkk
7/7/2008 3:50:10 AM
Can someone help me? I really don't know how to do that.
0
benjaminbkk
7/8/2008 2:50:05 AM
Reply:

Similar Artilces:

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...

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...

Login failed for user 'Bachelorplace'. The user is not associated with a trusted SQL Server connection. (.Net SqlClient Data Provider)
please tellme how to resolve this error, i m using server studio management tool. and trying to connect using sql server authentication. my pc is over a domain.   Login failed for user 'Bachelorplace'. The user is not associated with a trusted SQL Server connection. (.Net SqlClient Data Provider)  check whether that sql server is allowing sqlauthentication or not.select that server -> right click it-> select  properties  -> in the window, select security -> check what is the server authentication. it should be  sqlserver and windows authentica...

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...

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 ...

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',...

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...

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...

Submit Form to insert data into SQL and display with a gridview (edit as well) below how do i insert data into sql table?
I have an asp.net page that has a simple form where a user can submit customers information. Below that I have a gridview which displays customer information submited by the user who is logged in. I have the gridview displaying, sorting and updating as I want however I can't figure out how to bind a button click to insert data into the customer table and then have it refresh the gridview when they submit. Here is the basic code; (I am using AJAX for a calendar when a user wants to edit an appointment date) &lt;div class="leftBar"&gt; <div align=center&...

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 ...

Custom table data display based on current user log in
Hi All I am in really need of some help with ASP.net 2.0. I am trying to develop a site that when a user logs in will display only their data in a table or graph. Im using Visual Web Developer 2005 and sqlexpress 2005 I have setup one sql database called Customers.mdf with the table CustomerDetails and the other default aspnetdb.mdf which is created using the Website Admin Tool. Basically my user login IDs will be CustomerID numbers as in the customer table but when I create a user, for example User ID "1" this is stored in the aspnetdb.mdf. Therefore when I log in as this user I do not ...

Web resources about - Display data for logged in User only - asp.net.sql-datasource

Samples of display typefaces - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Bryce display sexist
Quentin Bryce was respected and admired during her tenure as Australia's 25th and first female governor-general.

iTunes Movie Trailers app gets iPad Pro display support, but no iOS 9 enhancements
Apple today has updated its iTunes Movie Trailers application with support for the higher-resolution display of the iPad Pro. The general interface, ...

New Sony Xperia C6 render shows off bezel-less display, looks drop dead gorgeous
... Xperia C5 Ultra, which was introduced back in mid-2015. Just like the C5 Ultra, the new Xperia C6 is expected to have a near bezel-less display, ...

Apple patents hover-sensing multitouch display
After the release of 3D Touch force-sensing input on iPhone 6s, Apple continues its push for the perfect input technology, most recently winning ...

New evidence points to future iPhones with holographic displays
It might sound like a bold prediction, but the iPhone will get a holographic display in the coming years. And this isn’t wishful thinking based ...

Guillermo Varela's Display Hints at a Bright Future at Manchester United - Bleacher Report
Guillermo Varela 's performance against Derby County hinted at a bright future for him at Manchester United . It was the 22-year-old's fourth ...

See lightning shred unsuspecting tree in display of nature's wrath
Watch a "wow" moment as lightning shatters a large tree and proves that you don't mess with Mother Nature.

Samsung display on truck's rear lets vehicles behind see road ahead
Samsung this week officially launched its first prototype of a semi-trailer truck with a large, high-definition display on the back so vehicles ...

iPad Air 3 may bring even sharper 4K display
The iPad Air 3 may boast a 4K display, as well as up to 4GB of RAM and improved battery life. Given that the current iPad Air has a resolution ...

Resources last updated: 2/5/2016 9:14:57 PM