0

I have a repeater which looks like so:

<HeaderTemplate>
    <div>
</HeaderTemplate>
<ItemTemplate>
<asp:PlaceHolder runat="server" id="plhContent"/>
</ItemTemplate>
<FooterTemplate>
    </div>
</FooterTemplate>

I then have a dataset that looks like:

Title | Category
"Title1","Legal"
"Title2","Legal"
"Title3","Finance"
"Title4","Accounting"

The dataset is sorted by the category.

And the output im trying to achieve is:

<div><!-- from headertemplate -->
    <div id="legal">
        <ul>
            <li>Title 1</li>
            <li>Title 2</li>
        </ul>
    </div><!--end legal div-->
    <div id="Finance">
        <ul>
            <li>Title 3</li>
        </ul>
    </div><!--end finance div-->
    <div id="Accounting">
        <ul>
            <li>Title 4</li>
        </ul>
    </div><!--end accounting div-->
</div><!-- from footertemplate -->

However I'm really struggling with the logic. Within my code i've essentially got:

Add a bulleted list
Add a listitem

But this poses a problem for the row "title2" because it doesnt require a new bulleted list, it just requires a new listitem to be added to the bulleted list in the previous iteration of the repeater.

How can i possibly do this?

Thanks in advance Al

1 Answer 1

1

An option would be to create some kind of temporary structure to hold the contents of the DataSet in a way that the Repeater will be able to handle to display the information the way you need it.

I'm thinking about turning it into a list of categories, and each category will be a list of items. Then you go through the DataSet items like so (pseudo-code):

for each item if category does not exist in list of categories create a list of "category items" add the item (title) to the list add this list to the list of categories else find the category add the item (title) to the list

The repeater should then be able to handle it

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.