Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Datalist spacing problem in asp.net

Posted on 2007-04-10
5
Medium Priority
?
348 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 12

Expert Comment

by:craskin
ID: 18885523
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 Ageil earned 2000 total points
ID: 18885687
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

Amazon Web Services EC2 Cheat Sheet

AWS EC2 is a core part of AWS’s cloud platform, allowing users to spin up virtual machines for a variety of tasks; however, EC2’s offerings can be overwhelming. Learn the basics with our new AWS cheat sheet – this time on EC2!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

705 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