Display Data to Current Logged in User With DVWP.

I have been working with DVWP and Sql Server for while.
During this time i was asked to Display Employee information based on who currently logged in.
When someone logged in sharepoint its store value in format rpatel\domain.com.I have employee table in Sql Server with column name lets say UserID which will have value rpatel.

I have Created Webpart to Display data from Sql Server for all Employees.
Now Add Parameters called LogonUser with Parameter Source and Server Veriable name LOGON_USER.
so now go to code view of DVWP and find XSL template dvt_1 and Modify line
<xsl:variable name="Rows" select="/dsQueryResponse/NewDataSet/Row"> 

with

<xsl:variable name="Rows" select="/dsQueryResponse/NewDataSet/Row[@UserID = substring-after($LogonUser,'\')]"/>

Enjoy

Ronak
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s