To Get the UserName from the ASP.NET membership tables using the UserID or Userkey the following snippet will work.
First add the Label Control in the .aspx page
<asp:Label ID="Label_UserInfo" runat="server" Text=""></asp:Label>
Now the snippet in the code behind, in the snippet if you have the UserID first we should convert into Guid
/* Getting User Name from User ID*/ Guid userKey = new Guid("5e5a79ca-321a-4158-ad8c-bdb42c5d02b4"); MembershipUser UserInfo = Membership.GetUser(userKey); Label_UserInfo.Text += UserInfo.UserName;
To use the MembershipUser you should have System.Web.Security Namespace