Getting A Username From A UserID (guid) In Web Forms?

Mar 26, 2011

So I'm almost finished my project but I'm stuck. In my application's database I save some records that contain the currently logged in user's userID - and so when it comes to displaying these records, I've been just been outputting the userID whilst developing the rest of the application. Through googling I've found this line of code that will get the a username based on a userID:

Dim membershipUser As MembershipUser = Membership.GetUser(New Guid(userGUID))

Which works great if I can supply it with a GUID - but I'm struggling to see how I can use this line of code if for example I want to show the usernames for comments on an article which are contained in a repeater control.Maybe it would be simpler to just merge my application's database with the asp.net membership database (ASPNETDB.mdf) so I can just select the username in SQL instead - but I'm not even sure how to do that.

View 1 Replies


Similar Messages:

Can't Insert A Guid (userID) Into Table!

Feb 10, 2011

I'm creating a web project for one of my uni modules using Visual studio 2010. I'm using asp.net membership and have all of my sql-server tables set up correctly (I'm pretty sure).

I have a form that I have created myself that inserts into the database using sqlDataSource.insert(). I had some problems initially with not being able to insert any data into the table at all, but I have cleared that up.

My problem now is that I need to insert the currently logged in user's userID into one of the columns of the table. But every time I hit the submit button, I am told I cannot insert null values in the userID column.

I can retrieve the userID using this snippet:

[Code]....

This is the code behind for the page:

[Code]....

As you can see it is a bit of a mess, I've been frantically trying different variations, as I need to catch up a little with other uni modules.

Here is my SQLDataSource from the .aspx page, The controlparameters work fine for the other data I am inserting. maybe the <asp:parameter name="userID" /> is wrong?

[Code]....

I'm relatively new to vb, and I come from a html & css background.

View 1 Replies

Security :: Where Is The UserID Guid On Login

Feb 11, 2010

We have a system where an administrator can login and create other users. If the administrator creates another user, then logs out and immediately logs back in with the new user information the UserID Guid is not available. If you log out and login again with the new username it works, or if you simply refresh the page it works.

Why does it not work on the first run?

View 1 Replies

Databases :: Use GUID As Userid When Using MySql For Membership?

Apr 23, 2010

I have followed this tutorial which provides me with Membership, Role, Profile etc.

[URL]

Everything is working fine, but I noticed that the userid is in standard INT, not GUID. Is it possible to get around this? I want the userid as GUID.

View 4 Replies

ADO.NET :: Insert Userid As System.Guid To The Uniqueidentifier Field?

Dec 12, 2010

I'm trying to insert userid that is a System.Guid into an additional table into the same userid field that is uniqueidentifier. It seems as it cannot insert the System.Guid type there wether I'm passing it directly as the System.Guid or as a String then converting.

<System.ComponentModel.DataObjectMethodAttribute _
(System.ComponentModel.DataObjectMethodType.Insert, True)> _
Public Function InsertUserInterests( _
ByVal strUserId As String, ByVal strCode As String) _
As Boolean
Dim userInter As New DS1.tblUserInterestsDataTable
Dim userInterRow As DS1.tblUserInterestsRow = userInter.NewtblUserInterestsRow
Dim ug As System.Guid = New Guid(strUserId)
userInterRow.UserId = ug ' This didn't go through I beleive
userInterRow.InterestCode = strCode
userInter.AddtblUserInterestsRow(userInterRow)
Dim rowsAffected As Integer = Adapter.Update(userInter)
Return rowsAffected = 1
End Function

View 3 Replies

Automapper, Auto Assign Guid To UserId Of UserDTO?

Dec 1, 2010

I want to assign Guid to UserId of my UserDTO if UserId is Null. Is it possible to do this in the CreateMap or creating any formatter?. I am using automapper as an attribute on my Actions in controller.

protected override void Configure()
{
Mapper.CreateMap<User, UserDTO>()
.ForMember(d => d.FullName, o => o.MapFrom(s => s.FirstName + " " + s.LastName));
}

View 1 Replies

State Management :: Get Username According To Userid & Use On Separate Web Forms In Website?

Oct 3, 2010

i 'm creating a website. i create a login form. after login my session will be start and all page of user profile will check first is session istart. i have stored userid in session for identify user. But i want to username of that userid. Remaiber username and userid are different. and i want to show only username on welcome tab.

e.g. userid= rksaini89
username= ramkrishn

so i want to show like this "welcome ramkrishn" on my home page and other many places on different forms. my confusion is that how to get username acording userid and where to keep store it. i can get it from database according session but i'm confused where to keep it so i can use it everywhere on my website.

View 1 Replies

Security :: Get UserId From UserName C#?

Jul 31, 2010

I am setting up membership and rolls for a small forum site that im working on. All this info is stored in the standard aspnetdb database. When a user is logged in and saves a post to the forum, their UserId is saved to a database in unique identifier format such as: b40e346d-0399-4bbb-90ee-c7c440726cfd. I want to set up a web service so that the name of the author of each post can be clicked on to retieve details about him or her. Rather than passing along the UserId of the author to the web service, I want to pass along the UserName and use that to retrieve the user's Id, which will in turn be used to query the database. I cant seem to find info on how to do this. I can find how to retrieve this kind of info for the current logged in user, but not any or all users in general.

View 5 Replies

Security :: Get Username From UserId?

Nov 16, 2010

How do I get the UserName from UserId by the following code?

[Code]....

View 2 Replies

How To Get UserName Or UserId From LoginName Control

Nov 14, 2010

I'm wondering is there any way i could get UserName or UserId for current User from LoginName control in ASP.NET ?

View 2 Replies

Security :: Get Username From Userid In Repeater?

Nov 17, 2010

I have the following code:

[Code]....

Can anyone show me some code, on how I get <%#Eval("UserId") %> to be the username instead of UserId.

View 6 Replies

Membership Provider Get UserName By UserId?

Jan 17, 2011

I have seen a lot of question asking about known user name and how to retrieve UserId accordingly. How about the other way around?

For some reason I have UserId, but I don't want to include aspnet_User table into my data entities. Is there any way I can retrieve the user name without querying against aspnet_User table?

View 1 Replies

Data Controls :: How To View UserID Username And Password Generated Using Configuration Tool

Dec 29, 2013

How to view the created id password in asp.net configuration

View 1 Replies

SQL Server :: Conversion Failed When Converting From A Character String To Uniqueidentifier - Match A Username To A Userid

Oct 12, 2010

I am trying to match a username to a userid which are in 2 different sql tables. Here is my select statement:

SELECT aspnet_Users.UserName
FROM aspnet_Users INNER JOIN
aspnet_starterkits_Projects ON aspnet_Users.UserName = aspnet_starterkits_Projects.ProjectManagerId

When I run this i get an error message: "Conversion failed when converting from a character string to uniqueidentifier" Is there anyway around this? Or a different select statement etc?

View 8 Replies

Active Directory/LDAP :: Get Unique ID Of UserName / Is GUID Is The Unique Id Of Each User

Nov 23, 2010

How to get Unique ID of LDAP logged in User? Is GUID is the unique id of each user?

View 1 Replies

C# - Adding Another Table Where UserID Can Have A Relationship With Another UserID?

Mar 31, 2011

I have a confusing question, I have a user table and it stores all the usual data for a user that you would expect but im trying to figure out how a user could add another user?

Sounds strange but each user in the User table has his own UI which is UserID how could I add another table where UserID can have a relationship with another UserID?

i.e how would I right the syntax for the above question if I wanted to display all the UserIDs friends on a page. How would I add a friend.

View 4 Replies

Security :: How To Retrieve UserID Off From The Session, Or Are There Other Ways To Retrieve UserID From

Jun 28, 2010

I have used session to the creation of user and led them to the edit page ..But how do I retrieve my userID off from the session, or are there other ways to retrieve userID from?

View 3 Replies

Security :: Update Username Of Current Logged Username?

Mar 12, 2010

How to update username of current logged username?

View 10 Replies

Web Forms :: Assigning GUID As Dropdownlist Value?

Sep 29, 2010

I am still new to ASP.net and it has been some time since i worked with code in general, so please forgive me for sounding stupid. I am using SQL to populate several drop down lists in a form, and later using the values selected to populate a datagrid. My issue is that the value i am trying to assign is a GUID in the database. So when I:

Do While (reader.Read())
Dim newListItem
As
New ListItem()Loop
newListItem.Value = reader.GetGuid(0)
newListItem.Text = reader.GetString(1)
Stat.Items.Add(newListItem)

I get an error stating :"Value of type 'System.Guid' cannot be converted to 'String'". My solution to this was to change "newListItem.Value = reader.GetGuid(0)" to

newListItem.Value = reader.GetGuid(0).ToString

that worked to generate the drop downs which was great, but now i am trying to use that value in a sql statement to populate a listbox and since the value is now a string, i cannot use it in my where clause to against a GUID field in the database. I would prefer to not have to convert the GUID in the first place, but have no idea how i could keep it in that format for my drop down list, and if that is not possible how can i convert the data back to GUID from String?

View 4 Replies

Web Forms :: Displays The First 9 Digits Of A GUID?

Apr 26, 2010

In the following question, I am using C# and ASP.NET 3.5:I am having a problem with a gift certificate program which requires a way to have the user retrieve a unique validation code consisting of the first 9 digits of a random GUID and the date and time. I have a page that has a button which creates these labels perfectly, but I can't figure out how to bind them to the certificate being validated This is the page described above:

[Code]....

I am open to calling another page called via a hyperlink like so:

View 4 Replies

Forms Data Controls :: Convert String To GUID?

Mar 6, 2011

I know there are about a million posts on this topic, and I have attempeted to use many of them. However, I keep getting an error when I attempt a simple SQL update. Here is my code:

[Code]....

Here is my error:

[Code]....

View 3 Replies

Web Forms :: How To Bind A Created Label That Displays The First 9 Digits Of A GUID

Aug 4, 2010

In the following question, I am using C# and ASP.NET 3.5:

I am having a problem with a gift certificate program which requires a way to have the user retrieve a unique validation code consisting of the first 9 digits of a random GUID and the date and time. I have a page that has a button which creates these labels perfectly, but I can't figure out how to bind them to the certificate being validated.

This is the page described above:

[Code]....

[Code]....

I am open to calling another page called via a hyperlink like so:

[Code]....

[Code]....

View 5 Replies

Web Forms :: Link Changes According To Userid

Apr 25, 2010

in social networking sites when we login in left side it shows link of our scrapbook and when we open on others persons profile these links open his scrapbook not ours. as i know that it links open according to user_id but how. what will be the code for that link so that link changes according to userid in asp.net. and one other question in our profile it shows link like profile edit, scrapbook, album, many more and when we open others it shows only few links how these link increase or decrease according to userid. Is these links comes from the dtatbase or somthing else. where these coding takes place in webform or in masterpage or any other place using c#

View 4 Replies

Forms Data Controls :: Assign On Page Load Current UsedID (GUID) To A Detailsview Field?

Nov 18, 2010

The detailsview is used for logged users to add a new item to a table in my sql database. The detailsview default mode is set to "insert".

The UserID is a field in the table in which the user enter the new record.

How can I get the UserID Guid value assigned automatically on pageload to the specific bound field in my detailsview

View 3 Replies

Web Forms :: Matching Logged In Userid To ID In Another Table?

Feb 2, 2011

So I have been trying to pull the userid of whoever is currently logged in and match it to another table that it is a fk in. I have some code that should work but I get an error that says specified cast is not valid in line 10.

here is the code I have behind file:

[Code]....

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved