Item Doesn't Save Filtered Lookup Attribute Properly

Nov 28, 2011 at 1:52 PM
Edited Dec 5, 2011 at 4:39 PM

Usually the list item is being saved after choosing a related item in the filtered lookup attribute. But in some cases, it's not possible to relate Item A to Item B. Relating Item A to Item C does work without any problems. Switching A -> C to A -> B afterwards deletes the content of this field and we're back at the beginning. Did anyone experience a similar behaviour? How is it possible to reach a solution for this problem? Any help would be appreciated! Thanks!

edit:
I actually got the error point: If you use the Source Project and go to FilteredLookupFieldControl.cs : GetCustomSelectValue(HtmlInputText txtBox), you'll find the following Code:
 Control h = FindControl(string.Format(CultureInfo.InvariantCulture, "{0}_Hidden", Field.InternalName));
      if (h != null && !string.IsNullOrEmpty(((HtmlInputHidden)h).Value)) {
        ListItem s = _availableItems.Find(x => (x.Value.ToLower() == ((HtmlInputHidden)h).Value.ToLower()));
        if (s != null && (s.Value != "0") && (s.Text.ToLower() == txtBox.Value.ToLower())) {
          return new SPFieldLookupValue(int.Parse(s.Value), s.Text);
        }

In some cases, s.Text does have a wrong Value (a space in between), so s.Text and txtBox.Value do not match. The referenced field is of type CalculatedField which does concat three values. The second value might be empty. And if it is empty, the problem occures!

Dec 5, 2011 at 4:45 PM

Workaround (fight the symptoms) is: don't compare s.Text and txtBox.Value, because the Id already has been checked, this should be OK.