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 had expected that if TryGetFieldByStaticName succeeds and returns a value, there would be an SPField in the item that has a static name equal to what I used in the TryGet... call, but no? I.e. can someone explain why the following piece of code outputs Value: a field value bot not here it is.

// page is SPListItem from Pages list
string stName = "CustomName";
try {
  Console.WriteLine("Value: " + page.Fields.TryGetFieldByStaticName(stName));
  foreach (SPField field in page.Fields) {
    if (field.StaticName.Equals(stName)) {
      Console.WriteLine("here it is");
} catch (Exception ex) {
  Console.WriteLine("Not Found");
share|improve this question

Can you check if this works:

    if (field.StaticName.Equals(stName, StringComparison.OrdinalIgnoreCase))
share|improve this answer
Same output, unfortunately. – claesv Oct 11 '12 at 6:46

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.