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 trying to replace all the spaces in my title to use as an ID, but I keep getting this error: error CS0103: The name 'Replace' does not exist in the current context

The code I am using is this: id="<%# Eval(Replace("Title"," ", "")) %>

id="<%# Eval("Title") %> works like a dream, and I have tried various ways to get the spaces removed, like Trim and Replace, but each gives me the above error.

can you help me format the right eval please? I am using SharePoint 2010 Enterprise edition.

Thanks Louise

share|improve this question
It seems like such a silly thing - but any .replace / .trims dont have definitions? – Louise van der Bijl May 7 '12 at 13:00
id="<%# Eval("Title").Replace(" ", "") %>" brings back :error CS0117: 'object' does not contain a definition for 'Replace' – Louise van der Bijl May 7 '12 at 13:03

My colleague gave me this ; id="<%# Eval("Title").ToString().Replace(" ", "") %>" and it worked! - Thanks for the help Christian!

share|improve this answer

could jQuery be an option for you? I think you can do this with an string replace function.

share|improve this answer
A friend suggested: String.Replace(Eval("Title"), " ", "") but I got this: error CS1501: No overload for method 'Replace' takes '3' arguments . Jquery is an option for me :) – Louise van der Bijl May 7 '12 at 12:56

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.