Sharepoint 2010 Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint 2010       RSS Feeds

How to fetch the username from person or group column in a list

  Asked By: Dharani    Date: Jul 20    Category: Sharepoint 2010    Views: 4296

SPSite spSite = new SPSite(Utility.GetTopLevelSiteUrl());
SPWeb tempSite = spSite.OpenWeb();
SPList splst = tempSite.Lists["T_Opportunity"];
SPQuery query = new SPQuery();
strResult = Convert.ToString(query);
SPListItemCollection colListItems = splst.GetItems(query);
SPListItem oitemlist = colListItems[0];
string createdBy = Convert.ToString(oitemlist["PreEngagementMQ1"]);
if (!string.IsNullOrEmpty(createdBy) && createdBy.Contains("#"))
createdBy = createdBy.Substring(createdBy.LastIndexOf("#") + 1);

txtpreengagementMQ1.Text = createdBy;

txtpreengagementMQ2.Text = currentOpportunityItem.PreEngagementMQ2Title;

Iam unable to bind the data to text box .Actually txtpreengagementMQ1 and txtpreengagementMQ2 have to bind.But here In my code I written for one.That one also not binding.please give some suggesstions on it.



1 Answer Found

Answer #1    Answered By: Bhupesh Karankar     Answered On: Oct 04

its in xslt

To get UserID

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="schemas.microsoft.com/.../designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:output method="html" indent="no"/>

<xsl:template name="GetUserID">
<xsl:param name="Person"/>
<xsl:value-of select="substring-before(substring-after($Person, 'ID='), '"')"/>


for more help, email me at bkarankar@karankar.com
make sure to put address as "SharePoint Help"