views:

52

answers:

2

I made a custom dropdownfield. I want to display the full names of my contacts. I made a calculated column because not every user filled in their full name, only first and last. If I wanna show the items in my dropdown there is always string;# before my value. Does somebody know how to remove that?

Here is the code where i fill my dropdown

SPWeb web = site.OpenWeb(); 
SPDataSource dataSource = new SPDataSource(); 
dataSource.List = web.Lists["Contacts"];
this.testing.DataSource = dataSource; 
this.testing.DataTextField = "Full Name"; 
this.testing.DataValueField = "Full Name"; 
this.testing.DataBind();

thx

A: 

Assuming full name is a text field, it looks like you have an error in your calculated column definition related to one of your inputs being a lookup field.

If you can't get rid of it in a cleaner way, there's always substr (or maybe right, I can never remember the syntax for excel functions)

Tom Clarkson
+2  A: 

The field type is probably "User" (I think shows as "People" in the UI). This and other lookup fields are always stored by SharePoint in this manner. The value component is the user ID and the string component is the user name.

You could use a Regex to split the components. You can also cast the value to SPFieldUserValue which is the 'proper' way, and use the properties on that class to retrieve info.

Alex Angas