SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using an gridview. The datasource is SPList.Items.GetDataTable().

The gridview is working fine; however, lookup and multilookup columns display as "id;#value". Is there any way to just show the value?

share|improve this question

Here is how I solved this issue:

<asp:TemplateField HeaderText="Campaign Members">
        <%# RemoveCharacters(Eval("CampaignMembers").ToString())%>

Make sure declare using System.Text.RegularExpression;:

protected string RemoveCharacters(object String)
    string s1 = String.ToString();
    string newString = Regex.Replace(s1, @"#[\d-];", string.Empty);
    newString = Regex.Replace(newString, "#", " ");
    return newString.ToString();
share|improve this answer

use SPBoundField in your gridview instead of BoundField

share|improve this answer
Okay. I tried SPGridView and spboundfield. I am still seeing the issue with lookupMulti where id;#value is showing when I have multiple values selected in the lookupmulti column. – Jamil Ferdaus Nov 28 '10 at 7:04

Alternatively, you could use SPFieldLookupValue (for a single lookup) and SPFieldLookupValueCollection (for a multi-lookup) to parse the field values using SharePoint's built-in methods for processing them.

Here is a revised version of your function for single lookups:

protected string RemoveCharacters(string fieldValue)
    SPFieldLookupValue value = new SPFieldLookupValue(fieldValue);
    return value.LookupValue;

I've also turned the parameter into a string since your XML passes one in.

Details on processing multiple lookups (and more) can be found in my blog article:

Easily accessing Lookup and User fields

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.