Display Username for the Logged on user on a page through a DataView

It is been a long time that I had penned down on Sharepoint Tip, One of our prestigious Client wanted me to display Current Logged on User Name, So here we go on Some Useful TIPS, The restriction was not to use the SharePoint Control i.e '<'wssuc:Welcome id="IdWelcome" runat="server" EnableViewState="false"'>' ''. But we can't write server-side code in SharePoint ASPX pages. The way I get around this limitation is to code XSLT and make it do what I want.


1. Insert a Data View Web Part on the Page. From any of the Lists drop a Title column on that dataview.

2. Click on Data > Conditional Formatting

3. Select any data value and Click on Create

4. Click on Show Content under conditional formatting.

5. Create a Condition that says: Title EQUALS [Current User] and click OK back to the Design view

6. Type “Welcome to this site“ inside one of the Table cells

7. Switch to Code view

8. Find the following code:

'<'ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"'/>'

9. Change this code to this:

'<'ParameterBinding Name="UserID" Location="CAMLVariable;ServerVariable(LOGON_USER)" DefaultValue="CurrentUserName"'/>'

10. Scroll up in the code and find “Welcome to this site”

11. Change code in front of your Welcome Message to this: “'<'xsl:value-of select="$UserID"'/>'

12. Save the page.

Hope this works for you !