Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8379531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:12:54+00:00 2026-06-09T16:12:54+00:00

I’m having trouble accessing the value of a calculated field from a list which

  • 0

I’m having trouble accessing the value of a calculated field from a list which is in a lookup field on another list in codebehind for SharePoint.

A ListFieldIterator on a page displays a load of options to a user. I need to perform some back-end validation on some particular selections the user has made.

I have a list called “Event Type” from which a user can select Play, performance, display etc. This list has 4 columns – description, enabled, default and filtered. Filtered is a calculated column which is generated based upon the options chosen on the other columns.

The list Events has a column which is a lookup to this list, and which displays the filtered column.

Now on the page this all works great. The options are displayed to the user and they can make their selection. Before adding the calculated field I could access the choice made by doing the below

SPFieldLookup eventTypeField = ListFieldIterator.Item.Fields.GetField("Event_x0020_Type") as SPFieldLookup;
if (eventTypeField.GetFieldValueAsText(ListFieldIterator.Item["Event_x0020_Type"]) == "Performance")
{
    // some other logic
    errorMessages.Add("There is an error here");                
}

Now however when accessing the field in this way I just get an empty string back.

If I attempt to access the chosen item with

string value = eventFields.Item["Event_x0020_Type_x0020_1"].ToString();

Then I get back “8” which is the position in the list of the item I chose. (it changes based on what item in the list I select)

This post Get value of calculate field seems related but I can’t see an obvious way to get a calculated field from the lookupfield.

Any suggestions appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:12:56+00:00Added an answer on June 9, 2026 at 4:12 pm

    It turns out that when using either a lookup column or a lookup column with a calculated field in, as I was, I was going about things the wrong way. This post put me onto the solution. The code is also below.

    Essentially I need to access the value stored in the control of the ListFieldIterator and not the value from the item. The code below (from the link above) provides a nice way to do this.

    public static List<T> GetControlsOfType<T>(this ControlCollection controls)
    {
      List<T> resultList = new List<T>();
      foreach (Control control in controls)
      {
        if (control is T)
          resultList.Add((T)((object)control));
        if (control.Controls.Count > 0)
        {
          resultList.AddRange(GetControlsOfType<T>(control.Controls));
        }
      }
      return resultList;
    }
    
    
    public object GetFieldValue(ListFieldIterator lfi, string fieldName)
    {
      FormField formField = lfi.Controls.GetControlsOfType<FormField>().Where(f => f.FieldName == fieldName).FirstOrDefault();
      if (formField == null) return null;
      return formField.Value;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a text area in my form which accepts all possible characters from
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.