Solved

Trouble with diving column items correctly

Posted on 2011-09-23
1
140 Views
Last Modified: 2012-05-12
I am trying to divide the items between 3 columns evenly and leave the remainder in the 3rd column.   However my code below keeps putting the last item back into the first column.   If you want to see what's happening, go to www.medicouponmanager.com and check out the bottom of the "select your health condition" section.  The last item is put back into the first column for some reason.  I want it to stay in the last.  

My code is below.   How can I fix this so that it ends up in the last column?
writer.WriteBeginTag("ul")
                If isRoot Then
                    writer.WriteAttribute("class", "KartrisMenu")
                Else
                    writer.WriteAttribute("class", "KartrisSubMenu")
                End If
                writer.Write(HtmlTextWriter.TagRightChar)
                writer.Indent += 1

                For Each item As MenuItem In items
                	intCounter += 1
                    BuildItem(item, writer)


If intCounter = Cint(items.Count/3) And intCounter >= Cint((items.Count/3)-1) then
	writer.Write("</ul><ul class=""KartrisMenu hide_me"">")
	intCounter = 0
End if

                Next

                writer.Indent -= 1
                writer.WriteLine()
                writer.WriteEndTag("ul")
            End If

Open in new window

0
Comment
Question by:saturation
[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
1 Comment
 
LVL 38

Accepted Solution

by:
Tom Beck earned 500 total points
ID: 36592409
Your last item ("Yeast Infections") is being put into a ul of its own.

<li class="KartrisMenu-Leaf">

                        <a href="/Womens-Health__c-p-0-0-75.aspx" class="KartrisMenu-Link">
                              Women's Health</a>
                  </li></ul><ul class="KartrisMenu hide_me">
                  <li class="KartrisMenu-Leaf">
                        <a href="/Yeast-Infections__c-p-0-0-70.aspx" class="KartrisMenu-Link">
                              Yeast Infections</a>
                  </li>
            </ul>


It's because of this statement:

If intCounter = Cint(items.Count/3) And intCounter >= Cint((items.Count/3)-1) then
      writer.Write("</ul><ul class=""KartrisMenu hide_me"">")
      intCounter = 0
End if

You have 73 items. If you divide by 3, you get 24 with a remainder of 1. You don't have any code to otherwise deal with this remainder so it is being put into a new ul. There's no more room for a fourth column of list items on the page, so it's being put at the bottom left, thus it appears to be at the bottom of the first column.

I think it would look nicer if the extra list item was in the first column. I would do this. Outside your loop, create a boolean value, Dim firstColumn As Boolean=true and a variable that holds the items.Count, Dim allItems As Integer = items.Count. Then change this statement to:

If firstColumn then
        If intCounter = allItems + (allItems Mod 3) Then
            writer.Write("</ul><ul class=""KartrisMenu hide_me"">")
              firstColumn = false
              intCounter = 0
        End If
else
        If intCounter = allItems/3 Then
            writer.Write("</ul><ul class=""KartrisMenu hide_me"">")
            intCounter = 0
        End If
End if
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

717 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