Solved

Datalist spacing problem in asp.net

Posted on 2007-04-10
5
337 Views
Last Modified: 2013-11-07
I'm trying to display a list of categories and sub categories in two columns.  I've got it working, but one thing I can't figure out is how to get rid of the excess spacing.  Basically if in the left column the first category only has 1 sub category and the category next to that on the right has 8, then there is a lot of empty space between categories on the left.

I've tried changing things like repeatlayout etc, but unfortunately I haven't had much luck.

I hope this makes sense.  

Here's my code:

-------------------

<asp:datalist id="MainCat" runat="server" onitemdatabound="MainCat_ItemDataBound" repeatcolumns="2" itemstyle-width="381px" itemstyle-verticalalign="Top">
<ItemTemplate>

<strong><a href='category.aspx?MainCategory=<%#DataBinder.Eval(Container.DataItem, "HBI_CAT_ID")%>'><%#DataBinder.Eval(Container.DataItem, "HBI_CAT_NAME")%></a></strong><br />

    <asp:repeater id="SubCat" datasource='<%# Container.DataItem.Row.GetChildRows("myrelation") %>' runat="server">

        <itemtemplate>
            &nbsp;&nbsp;&nbsp;- <a href='category.aspx?SubCategory=<%#Container.DataItem("HBI_SUBCAT_ID")%>'><%#Container.DataItem("HBI_SUBCAT_NAME")%></a><br />
        </itemtemplate>

        <footertemplate>
            <br />
        </footertemplate>

    </asp:repeater>


</ItemTemplate>


My results currently display like this:

Cat 1                          Cat3
Sub cat 1                    Sub cat 1
                                  Sub cat 2
                                  Sub cat 3
                                  Sub cat 4
                                  Sub cat 5

Cat 2
Sub cat 1

But I would like them to display like this:

Cat 1                          Cat3
Sub cat 1                    Sub cat 1
                                  Sub cat 2
Cat 2                          Sub cat 3
Sub cat 1                    Sub cat 4
                                  Sub cat 5

thanks

0
Comment
Question by:Saroj13
5 Comments
 
LVL 12

Expert Comment

by:craskin
Comment Utility
i believe the datalist uses tables instead of div tags to render out (you can check by viewing the source once you've browsed to it). if so, i don't think there could be a way around it other than using a repeater and doing the layout yourself.
0
 
LVL 27

Accepted Solution

by:
Sammy earned 500 total points
Comment Utility
The most elegant way to to this is by using CSS adapters
you can look at them here
http://www.asp.net/cssadapters/
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now