Replace user id with user name


I'm sure this has to be simple but so far I'm having problems finding a solution. I have two data tables:

T_Users (id, lname, fname, etc...)

T_EventDetails (id, user1, user2, user3, date, etc)

These tables are not associated with each other (pk, fk, etc) and are part of a larger system. The "user" fields in T_EventDetails are populated with the "id" data for the various users from a set of DDLs on the main page. The DDLs get their data from the T_Users table (DataValueField="id") and each row in T_EventDetails will have four user-related entries. This all works fine and I can output the data in a datagrid, etc. Problem is, I need to display the user names (fname lname) and not the user id values.

In the past (ASP 3.0) I have used a replace function to change this data but not sure how to do this in ASP.NET. Any ideas, examples, etc would be appreciated....thanks in advance.


2/13/2008 6:55:42 PM 72751 articles. 3 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 9

You could use this SQL to get the names:

	user1_name = (SELECT fname + ' ' + lname FROM T_Users WHERE id = user1),
	user2_name = (SELECT fname + ' ' + lname FROM T_Users WHERE id = user2),
	user3_name = (SELECT fname + ' ' + lname FROM T_Users WHERE id = user3)
FROM 	T_EventDetails
2/13/2008 7:31:58 PM

Thanks for your quick reply. Tried the code as sent (changed values of course) in a code-behind and got this error:

 DataBinding: 'System.Data.Common.DataRecordInternal' does not contain a property with the name 'ID'.

 I know the T_Users table has an ID field so I am at a bit of a loss - any thoughts?


Thanks again...


2/13/2008 7:58:59 PM

Never mind - I figured it out - mssing the ID field in the overall SQL statement, not in the sub-queries.

 Thanks again, works great!! Big Smile

2/13/2008 8:03:53 PM

Similar Artilces:

user control to user control
I have an aspx page that have a "Register" directive to two usercontrol called rptMaster.ascx and rptDetail.ascx. I'm trying to set up a Master-Detail relationship and wish for the rptMaster.ascx to trigger and event from a dropdownlist and for the rptDetail to be listening for DropDownList event. I believe I have gotten the events part okay with help from this articel but my declaration for a private statement to my rptMaster class is producing an error. I'm using beta 2 of and I 'm having trouble getting a reference TO ...

User Control in a User Control
I have a first user control that contain a second user control. If I cahe the first user control can I still dynamically control the second one or it is cached with the first one therefore can not control it anymore? Thanks When your first control is cached, its rendered out and its output is stored in the cache. On every request to the page containing your control that can satisfy it from cache, the output will just simply be inserted - your first control will never be instantiated or run in that case, so the second one wont be either. Hope this helps,Mike VolodarskyProgram Manager...

User control in a user control
Hello all, I have created a user control with some checkboxes, and public properties to get the values of these checkboxes. I have also created a second user control using the first user control; this second control also access the public properties of the first one. My problem is when I implement the second control in an aspx page, if I click at runtime the checkboxes in the first control, I am able to access its public properties from the methods of the second control but the values of these properties are wrong. while at design time, I do not have this problem. Than...

User Controls in User Controls?
I have the follow set up and it is throwing an error "Unhandled error loading module" ... is there some trick to this that I don't know?I have a project A that uses controls from project B (project B is just a project with all my user controls used through out other modules).  project A uses user control 1 from project B with out any issues at all - great.  But then I wanted to add user control 2 to user control 1 and that is when I get my error.  In fact I don't even have the user control 2 in user control 1, just when I put the register part into user control 1 is when it al...

User Control
I am trying to convert my aspx page that has all my graphics into a header user control, in the page I reference the username that is logged into the site.  I am using the User.Identity.Name function but it tells me that User is not identifited.  This worked just fine before I moved it to the ascx page. Anyone have any ideas? Thanks Craig In a user control or custom control your will need to use either:Page.User.Identity.Name orHttpContent.Current.User.Identity.Name If using the latter, don't forget to import the System.Web namespaceBill, WESNet Designs...

User.Identity.Name in User Control
Can I use User.Identity.Name in a User Control (.ascx file). I tried to use it but got the following error: " The type or namespace name 'User' could not be found (are you missing a using directive or an assembly reference?) " regards Try using HttpContext.User.Identity.Name HTH... Chris...

get user name by user id
hi i send the user ID to a page and there i wanna find the user name. can you please let me know how to find a user name by user id? tanks  Are you using Active Directory? If so check out this tutorialCommunity Coder Hi you can pass the Guid USerId to Membership.GetUser method,MembershipUser usr = Membership.GetUser(UserIDAsGuid); string userName = usr.UserName; // to get the current logged in username , just use HttpContext.Current.User.Identity.Name;    Regards,Anas Ghanem.Note:Please Don't hesitate to click "Report Abuse" link if you noticed som...

User.Identity.Name in User Control
What namespace do I have to include in my User Control code behind to be able to access the Forms Login User.Identity.Name information? Thanks!I haven't failed, I've found 10,000 ways that don't work System and System.Web.UI. Here's a sample of a user control retrieving User.Identity.Name: using System; using System.Web.UI; public class MyClass: Page { public void Page_Load(Object Source, EventArgs e) { Response.Write("User.Identity.Name=" + User.Identity.Name); } } Thanks lauraThis posting is provided "AS IS"...

Web user control inside update panel replace with another web user control
 Hi there. I have a page with a menu. an and then the content. My thing is. That i have the update panel, and inside that i have a regual panel in which i add the Web User Controls i need. Which all works fine. My problem is. That i i have a submit funcion on almoast all the Web User controls. What i would like is that i inside that update panel, can dispose the original Web user Control and then add a response Web User Control. In normal language. Is there a way that i can load one web user control into antoher and then disposose the original? Thanks in advance hello. well, what ...

Added prefix to form control id/name when in user control
I have noticed when including user controls that have form elements in a page, those form elements' IDs/Names are prefixed with the user control's ID and an underscore (_) or colon (:). For example, let's say you have a page that contains a user control with the ID "ctlControl". That control contains a textbox with the ID "txtSomething". The rendered HTML presents you with the textbox, but the name is now "ctlControl:txtSomething" (and sometimes it comes up as "ctlControl_txtSomething" -- I haven't figured out why it isn't consistent...but that is...

User.Identity.Name and Web User Control,
I am trying to user User.Identity.Name.ToString in a WebUser Control but it doesnt seem to work. Is their any way around this its tells me "User.Identity " is undeclared. Here is the code that was working when the form was still a web form.   CurrentRow.Item(5) = User.Identity.Name.ToString EmployeeDataTable.GetChanges() EmployeesAdapter.Update(CurrentRow)  It think it needs an import stsaement at the top can you help? Thnks Sanson Use System.Web.HttpContext.Current.UserThanks, EdMicrosoft MVP - ASP/ASP.NET thank you! Thanks for the advice. I couldnt actual...

User name from Web User Control context
Hi I had some code on my page that retreived a user's name ( string AddedBy = User.Identity.Name; But when I try to use the same line of code in web user control code behind I get an error: Error 1 The name 'User' does not exist in the current context   How can I get user's name in web user control code behind. Try using: Page.User.Identity.NameMike Banavige~~~~~~~~~~~~Need a site code sample in a different language? Try converting it with:

want to call one function in one user control from another user control
hi i have two user controls info.ascx and personal.ascx i have a function like in info.ascx i have a function like showdetails() {   } now i want to access this function from personal.ascx can i do this ? thanks in advance. shwetaThanksshwetaIn a day when don't come across any problem -you can be sure that you are traveling in wrong path  you should better create a class where you will define the "functions" that you need in both files. declare "static" the function and call it like nameofclass.nameoffunction In a web project you can...

Unable to access user control's user control's function\property from another user control
Hi, I used to call an user control's user control function as stated below from my user control in ASP.Net 1.1 wucCompany.wucEmployee.GetEmployeeSomething() After migrating to ASP.Net 2.0, I am unable to use any properties/functions(even the public ones) of the user control's User control's from another user control.  The way I have to do is create property\function in wucCompany which calls the wucEmployee's property\function and call the wucDepartment.GetEmployeeSomething().Since I need to do this change in too many places, I can...

Web resources about - Replace user id with user name -

File:Replace this image male.svg - Wikipedia, the free encyclopedia
to an image (e.g. you photographed or drew it yourself) and would like Wikipedia to use it, you must release it under a free copyright license ...

‘Pages And Public Figures’ Replaces ‘Following’ In Facebook’s News Feed Menu
Facebook appears to have slightly altered its News Feed options , changing the listing for “Following” to “Pages and Public Figures.” continued… ...

Facebook replaces ‘brand resource center’ with new website and assets
Facebook has launched to replace its previous brand resource center. The new site is more visual and offers additional guidance ...

Funny Movie Maker - Replace Your Face on the App Store
Read reviews, compare customer ratings, see screenshots, and learn more about Funny Movie Maker - Replace Your Face. Download Funny Movie Maker ...

NASA just chose SpaceX to replace the Shuttle for flying astronauts
jurvetson posted a photo: Elon's design goal = "the safest, most advanced crew vehicle ever flown.” With seats for seven . First manned flight ...

Surface Pro 3: The tablet that can replace your laptop. - YouTube
With a 12" display, Surface Pro 3 has the power of a laptop in a lightweight, versatile form. In this TV ad, with one continuous take the camera ...

Ministry of Labour replaces plastic cards with e-cards - The National
... printed out and accessed by employers and employees, and documents will be linked to Emirates ID. Those already employed will not have to replace ...

Change of the Day: Canadian Town Wants to Replace Its ‘Land of Rape & Honey’ Motto
The town of Tisdale in Saskatchewan has had a very unfortunate slogan for the past 60 years, and they’re finally looking for a new one. Visitors ...

ASI helps Cloud wholesaler replace Cisco hardware with Brocade rentals
ARNnet ASI helps Cloud wholesaler replace Cisco hardware with Brocade rentals ARNnet Cloud Plus is transitioning from Cisco to Brocade hardware ...

Replace petrol taxes with pay-as-you-go road charging, experts say
The rise of fuel efficient cars will force governments to look for alternatives to petrol taxes, a roads conference heard on Monday, with advocates ...

Resources last updated: 1/14/2016 8:47:25 AM