Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I tried to display several ListItems, each with a ListFieldIterator, but all the LFIs display the same Item (the first one assigned). Is there a way to have each Iterator Display the Item it got assigned? Or is this a bug/not possible? I have to do it in code, I haven't tested if it works when declaring each LFI in the ASPX file.

This is my code

foreach (var article in articles)
{
    count++;
    ListFieldIterator lfi = new ListFieldIterator();
    lfi.ListId = listId;
    lfi.ID = "lfi_" + count;
    lfi.ItemId = article.Article.Id.Value;
    lfi.ControlMode = SPControlMode.Display;
    ArticlesPanel.Controls.Add(lfi);
}
share|improve this question
add comment

1 Answer 1

I don't have a development machine at my disposal right now, but this might be related to not disposing the ListFieldIterator.

Try something like this, though I cannot guarantee that it'll fix it:

using (ListFieldIterator lfi = new ListFieldIterator())
{
    lfi.ListId = listId;
    lfi.ItemId = article.Article.Id.Value;
    lfi.ControlMode = SPControlMode.Display;
    ArticlesPanel.Controls.Add(lfi);
}
share|improve this answer
    
Hi thanks for your answer, unfortunately it did not work. But you got my hopes high for a few minutes :) Well I had to solve it differently now. I iterate over every item and build the controls in code. Still it would interest me if it is possible to have several ListFieldIterators. –  Kirschi Jun 11 '13 at 9:46
add comment

Your Answer

 
discard

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.