Solved

Datalist spacing problem in asp.net

Posted on 2007-04-10
5
347 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 500 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

630 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