Create a replication of this in VB.NET using an ASPX Repeater to iterate over the specified content

Need help with repeating the following code in vb.net/asp.net:

<ul id="prod_nav" class="clearfix">
      <li class="top"><a href="05-Pink-02-Category-List.html" class="top_link"><span class="down">Body and Trim</span></a>
        <ul class="sub">
          <li class="clearfix">
            <ul>
              <li><a href="05-Pink-03-Products-List.html">Panels</a></li>
              <li><a href="05-Pink-03-Products-List.html">Tow Bars</a></li>
            </ul>
          </li>
        </ul>
      </li>   <li class="top"><a href="05-Pink-02-Category-List.html" class="top_link"><span class="down">Brake Friction</span></a>
        <ul class="sub">
          <li class="clearfix">
            <ul>
              <li><a href="05-Pink-03-Products-List.html">Drums</a></li>
              <li><a href="05-Pink-03-Products-List.html">pads</a></li>
              <li><a href="05-Pink-03-Products-List.html">discs</a></li>

            </ul>
             </li>
        </ul>
      </li>     

Here is what I have so far:

<asp:Repeater ID="repeaterMyList"  Runat="server">
            <HeaderTemplate>

            </HeaderTemplate>
                <ItemTemplate>
                   <li class="top"><a href="javascript: void(0)" class="top_link"><span class="down"></span><%#DataBinder.Eval(Container.DataItem,"groupname")%></a>

          <ul class="sub">
          <li class="clearfix">
            <ul>
              <li><a href="05-Pink-03-Products-List.html"><%#DataBinder.Eval(Container.DataItem,"subgroupname")%></a></li>




                </ItemTemplate>
                <SeparatorTemplate>

            </ul>
                </SeparatorTemplate>
                <FooterTemplate>

                </li>
        </ul>
      </li>
                </FooterTemplate>
            </asp:Repeater>
        </ul>

Issue: The datatable has all the necessary columns but only one master <li> is being displayed.

If you can assist me, it would be greatly appreciated. Thank you!

GROUPID   GROUPNAME           SUBGROUPID SUGROUPNAME
BO  Body & Trim PANE-BO Panels
BO  Body & Trim TOWS-BO Tow Bars

BR  Brake Friction  DRUM-BR Drums
BR  Brake Friction  PADS-BR Pads
BR  Brake Friction  KITS-BR Accessories-Fit Kits
BR  Brake Friction  DISC-BR Discs
BR  Brake Friction  SHOE-BR Shoes
CA  Cables  CABL-CA Cables
CA  Cables  CAFP-CA Cable Fitment Parts
CL  Clutch Friction SSCL-CL Switches, Sensors - Clutch
CL  Clutch Friction CLPT-CL Clutch Parts, Flywheels
CL  Clutch Friction CLFP-CL Fitting Parts
CO  Cooling & Heating   RCTS-CO Radiator Caps, Thermostats
CO  Cooling & Heating   SSCH-CO Switches, Sensors - Cooling & Heating   
CO  Cooling & Heating   WHOP-CO Water Hoses, Pumps

Answer №1

If you're looking to achieve nested repeaters for your data, the key concept to focus on is:

Nested repeaters

You can find numerous examples on StackOverflow and other platforms.

In essence, you'll need one repeater for your groups, and another repeater within that for your subgroups.

It's challenging to provide specific guidance without alignment between your data table and code snippet (e.g., the group Bathroom may not be evident in your data).

EDIT:

Below is a fundamental example of markup for a nested repeater:

<asp:Repeater ID="rGroups"  Runat="server">
    <HeaderTemplate>
        <ul id="prod_nav" class="clearfix">
    </HeaderTemplate>
    <ItemTemplate>
        <li class="top"><a href="05-Pink-02-Category-List.html" class="top_link">
            <span class="down"><%#DataBinder.Eval(Container.DataItem,"groupname")%></span></a>

        <asp:Repeater ID="rSubgroups"  Runat="server">
            <HeaderTemplate>
                <ul class="sub">
                  <li class="clearfix">
                    <ul>
            </HeaderTemplate>
            <ItemTemplate>
                <li><a href="05-Pink-03-Products-List.html"><%#DataBinder.Eval(Container.DataItem,"subgroupname")%></a></li>
            </ItemTemplate>
            <FooterTemplate>
                    </ul>
                  </li>
                </ul>
            </FooterTemplate>
        </asp:Repeater>

        </li>
    </ItemTemplate>
    <FooterTemplate>
        </ul>
    </FooterTemplate>
</asp:Repeater>

The rSubgroups repeater must be bound for each item in the rGroups repeater. To accomplish this, implementing the OnItemDataBound event of rGroups is necessary.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Box surrounding the image with a shade of gray, all thanks to

Despite trying to set "outline: none" and tweaking the border, I'm unable to resolve the issue. For reference, you can visit the page here: . I've shared the link because I'm unsure of what exactly needs fixing or adding on the page. Any gui ...

The issue with the custom select feature in beautiful soup 4 is causing malfunctions

Check out this Bootstrap 4 example: https://getbootstrap.com/docs/4.0/components/forms/#select-menu I've implemented it on my website: <select class="custom-select"> <option value="1">Telegram</option> <option value="2">W ...

Chrome does not recognize the 'position: fixed' style attribute

Encountered an issue in Chrome where the position:fixed property does not behave as expected. While this code works fine in Firefox and Safari, it seems to have a glitch in Chrome (69.0.3497.100). When scrolling, the blue div moves and reveals the green ba ...

Modifying the website URL in Visual Studio 2015: A Step-by-Step Guide

I've been struggling to find a solution to a challenge I've encountered in Visual Studio 2015. Currently, my website URL is set to localhost:9045, but I need to change it to a different port number and path, specifically localhost:54865/central. ...

Avoiding navigation bar overlap in CSS techniques

I have successfully implemented dropdown navigation with absolute positioning, but it is causing the left side to squash and the content above it to be hidden behind the navigation. Is there a way to prevent my navigation from overlapping other content wh ...

The Azure Website is unable to identify the Table in my Database following a Schema modification

My Microsoft Azure Website is up and running smoothly with an Azure SQL Database for managing user accounts. However, I also wanted a mobile client, so following various online tutorials like THIS, I had to modify the database table's 'schema&apo ...

Bootswatch alternative for Bootstrap CSS without utilizing Google Fonts

Currently, I am in the process of developing a webpage and utilizing Bootswatch for styling. However, there are times when I need to work offline and host locally. The issue I am facing is that Bootswatch cannot be used offline due to the fact that it util ...

Class name that changes the cursor to a pointer shape in CSS

My question is: Are there any CSS classes or attributes in Bootstrap 4 specifically designed for applying the pointer: cursor property to buttons or links? <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel= ...

What is the best way to make the buttons on my website shift downwards?

I'm currently working on making my website mobile-friendly. I've managed to stack the buttons on top of each other when the width reaches 700, but now I'm struggling to make them move down the screen. Some resources suggest using absolute po ...

Issue with FiFO on MacOs causes skewed borders to not display correctly

I am currently facing an issue with my webpage and would greatly appreciate some help from the community. My goal is to create a skewed border inside a div, similar to the example on this JSFiddle link: https://jsfiddle.net/kx6f9rsd/ .container { backgro ...

Delivering a RESTful API using ASP.NET MVC to interact with AngularJS

When working with the $resource object in AngularJS, I'm encountering a situation where it has a single URL for all REST calls. In the case of $resource.get and $resource.delete, they both call a URL like /app/customer/8. How can I distinguish between ...

Resolve a container overflow problem within the footer section

Trying to adjust the footer (newsletter signup form) on this page to fall to the bottom of the page has been a challenge. The #container element appears to be larger than the body, causing layout issues. Any suggestions on how to resolve this? An image d ...

What is the best way to create a blurred effect on an image during loading, and then transition to a sharp image once it is fully loaded?

I'm currently working on a project where I want the images to display as a blurred preview initially, and then become clear once fully loaded. This is similar to the feature seen on Instagram, where the app shows a blurred image before displaying the ...

Trouble arises when implementing personalized buttons on the Slick JS slider

Are you struggling to customize buttons for your Slick Slider JS? I am facing a similar issue with applying my own button styles to the slider. I am interested in using arrow icons instead of the default buttons. Here is the HTML code snippet: <secti ...

Targeting child elements with CSS selectors

In my ecommerce software, I have a menu that I want to customize by making the main categories bold. I have attempted various methods, including the ones shown below, but I am struggling to target the correct elements (specifically those in capital letter ...

Tips for placing a button on top of an image

Greetings and well wishes during this unique period we're currently experiencing! Can anyone share how to position a button over an image (located here)? I am utilizing Visual Studio, Jekyll, and Github. After attempting to copy and paste the exact ...

Conceal a Tag with CSS

Looking to conceal a label using CSS <p class="half_form "> <label for="property_bathrooms">Bathrooms (*only numbers)</label> <input type="text" id="property_bathrooms" size="40" class= ...

The value that was verified disappears after the postback

I found a helpful tutorial on creating image checkboxes and decided to implement it. Check out the tutorial here Initially, everything seemed to be working well. However, upon page post back, the checked element was lost and I couldn't retrieve it. ...

Unable to invoke a second method - asp.net and c# not responding

public static int EmployeeNumberUpdate(string empToUpdateFrom, string empToUpdateTo) { string sql; int returnValue; using (connection = new SqlConnection(DatabaseConnectionString())) { connection.Open(); sql = "uspUpdateDeta ...

Expanding a div container to accommodate its inner divs using CSS

I have a div containing three inner divs. ONE - I am div TWO - I am div THREE - I am div When viewed on mobile, only two divs can fit in a row horizontally. I want the third div to move down. Like this: ONE - I am div TWO - I am div THREE - ...