reproduce this in vb.net in an asp:repeater i need to repeat the following
-
12-11-2019 - |
Question
I need to repeat the following 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>
so ar i have
<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>
Problem : The datatable I have referenced the repeater in, has the columns for example but im only getting one master <li>
.
Created please can someone help me out here.
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
Solution
Instead of the full solution which would involve more than just the markup for the repeater, here is the most important subject you should look into to pull this off:
Nested repeaters
Tons of examples on StackOverflow and elsewhere.
Basically, you'll want a repeater for your groups, and and inner repeater for your subgroups.
Hard to be more specific because the data table you mention in your question does not correspond to the markup sample provided (for example, the group Bathroom cannot be found in your data example).
EDIT:
Here's the basic 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 needs to be bound for each item in the rGroups repeater. In order to do that, you'll need to implement the OnItemDataBound
event of rGroups