views:

199

answers:

1

I am binding a generic List to an <asp:ListView /> control to display a tag cloud. The elements in the list are Tag objects, where Tag is basically just something like:

public class Tag {
    public string Name { get; set; }
    public int Total { get; set; }
}

I create the List<Tag> object and then bind it to a ListView but when the HTML is rendered for the page certain Tag objects are repeated e.g. given the expected tag list of apple, banana, kiwi, orange, strawberry the HTML would actually output something like apple, banana, apple, apple, strawberry.

I am writing out the contents of my underlying List<Tag> to the Trace.axd and that shows the elements to be in the correct order without duplicates.

Has anyone ever come across something similar?

+1  A: 

Could you put some more code up? Perhaps you are using some reference variables that are using the same memory location? It's hard to tell with the code you uploaded.

dirq
I had messed up the sorting of the Tag objects in my Tag<List>, hence the strange order they were appearing in when output to the browser.
Ian Oxley