Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Trouble with diving column items correctly

Posted on 2011-09-23
1
Medium Priority
?
143 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

610 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