Using Bootstrap tabs with ASP NET repeater

bjornlof

I have an aspx page which uses a repeater to show a number of panels like so:

<asp:Repeater ID="myRepeater" runat="server">
    <ItemTemplate>
        <div class="panel panel-default">
            <div class="panel-heading">
                <h1>
                    <asp:Label ID="lbHeader" runat="server"></asp:Label>
                </h1>

                <ul class="nav nav-tabs" role="tablist" id="myTab">
                    <li class="active"><a href="#tab1" role="tab" data-toggle="tab">Tab1</a></li>
                    <li               ><a href="#tab2" role="tab" data-toggle="tab">Tab2</a></li>
                    <li               ><a href="#tab3" role="tab" data-toggle="tab">Tab3</a></li>
                </ul>
            </div>

            <div class="panel-body">
                <div class="tab-content">
                    <div class="tab-pane fade in active" id="tab1">

                        <%--Tables and stuff--%>

                    </div>

                    <div class="tab-pane fade" id="tab2">
                        Some text
                    </div>

                    <div class="tab-pane fade" id="tab3">
                        Some other text
                    </div>
                </div>
            </div>
        </div>
    </ItemTemplate>
</asp:Repeater>

It looks something like this:

+------------+--------+---------+---------+
| Panel 1    | *TAB1* |  Tab 2  |  Tab 3  |
+------------+--------+---------+---------+
|  Some text and tables                   |
|                                         |
+-----------------------------------------+

+------------+--------+---------+---------+
| Panel 2    | *TAB1* |  Tab 2  |  Tab 3  |
+------------+--------+---------+---------+
|  Some other text and tables             |
|                                         |
+-----------------------------------------+

So by clicking on different tabs you'll see different information in the panels.

You can change the information in Panel 1 by clicking on Panel 1's different tabs but when you click on Panel 2's tabs it's not Panel 2's info that change but Panel 1's!

What should I do to make Panel 1's tabs change the info in Panel 1 and Panel 2's tabs change the info in Panel 2?

Aristos

The issue here is that the id is repeated the same on each line, and you need to change that to different id on each line.

To do that I use a public integer on code behind like that:

public int cLine = 0;

and use it on repeater to add it to the id, and increase it on each new line as:

<asp:Repeater ID="myRepeater" runat="server">
    <ItemTemplate>
        <div class="panel panel-default">
            <div class="panel-heading">
                <h1>
                    <asp:Label ID="lbHeader" runat="server"></asp:Label>
                </h1>

                <ul class="nav nav-tabs" role="tablist" id="myTab<%=cLine%>">
                    <li class="active"><a href="#tab1<%=cLine%>" role="tab" data-toggle="tab">Tab1</a></li>
                    <li               ><a href="#tab2<%=cLine%>" role="tab" data-toggle="tab">Tab2</a></li>
                    <li               ><a href="#tab3<%=cLine%>" role="tab" data-toggle="tab">Tab3</a></li>
                </ul>
            </div>

            <div class="panel-body">
                <div class="tab-content">
                    <div class="tab-pane fade in active" id="tab1<%=cLine%>">

                        <%--Tables and stuff--%>

                    </div>

                    <div class="tab-pane fade" id="tab2<%=cLine%>">
                        Some text
                    </div>

                    <div class="tab-pane fade" id="tab3<%=cLine%>">
                        Some other text
                    </div>
                </div>
            </div>
        </div>
        <%cLine++;%>
    </ItemTemplate>
</asp:Repeater>

At the rendered html part you see this code tab1<%=cLine%> to render as tab10, tab11, tab12 etc.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Convert Bootstrap Carousel to ASP.Net Repeater

From Dev

Convert Bootstrap Carousel to ASP.Net Repeater

From Dev

ASP .NET Using a Repeater inside of UpdatePanel with UpdateProgress

From Dev

To bind images in repeater using asp.net

From Dev

.NET 4.5, LINQ, Bootstrap tab control, and asp:Repeater

From Dev

How to render two column layout using an asp.net repeater

From Dev

ASP.Net repeater control - using conditional statements

From Dev

How To Make Slideshow Using ASP.NET Repeater

From Dev

Display different pages in Bootstrap nav tabs in asp.net

From Dev

NavigateUrl on Repeater ASP.net

From Dev

NavigateUrl on Repeater ASP.net

From Dev

Using foreach with ASP.NET view engine inside a ASP: Repeater is not working

From Dev

Changing the last datarow from a asp:repeater table if data is shown in asp:label using vb.net

From Dev

Making accordions with tabs in asp.net using jquery

From Dev

Open Ajax TabContainer tabs using query string in Asp.net

From Dev

ASP.NET Repeater - Eval() for bool?

From Dev

asp.net repeater for each row

From Dev

repeater item command in asp.net

From Dev

to disable a label of repeater on some condition in asp .net

From Dev

asp.net repeater use template in javascript

From Dev

asp.net repeater merge columns dynamically

From Dev

Fix header row in repeater in ASP.NET

From Dev

ASP.NET Converting repeater item to the textbox

From Dev

Repeater asp.net tag not working

From Dev

asp.net repeater merge columns dynamically

From Dev

Conditional statement for Repeater Controll in ASP.NET

From Dev

Fix header row in repeater in ASP.NET

From Dev

trying Image Button in repeater Asp.net

From Dev

asp net dropdown selectedvalue/selectedindex not updating in repeater

Related Related

  1. 1

    Convert Bootstrap Carousel to ASP.Net Repeater

  2. 2

    Convert Bootstrap Carousel to ASP.Net Repeater

  3. 3

    ASP .NET Using a Repeater inside of UpdatePanel with UpdateProgress

  4. 4

    To bind images in repeater using asp.net

  5. 5

    .NET 4.5, LINQ, Bootstrap tab control, and asp:Repeater

  6. 6

    How to render two column layout using an asp.net repeater

  7. 7

    ASP.Net repeater control - using conditional statements

  8. 8

    How To Make Slideshow Using ASP.NET Repeater

  9. 9

    Display different pages in Bootstrap nav tabs in asp.net

  10. 10

    NavigateUrl on Repeater ASP.net

  11. 11

    NavigateUrl on Repeater ASP.net

  12. 12

    Using foreach with ASP.NET view engine inside a ASP: Repeater is not working

  13. 13

    Changing the last datarow from a asp:repeater table if data is shown in asp:label using vb.net

  14. 14

    Making accordions with tabs in asp.net using jquery

  15. 15

    Open Ajax TabContainer tabs using query string in Asp.net

  16. 16

    ASP.NET Repeater - Eval() for bool?

  17. 17

    asp.net repeater for each row

  18. 18

    repeater item command in asp.net

  19. 19

    to disable a label of repeater on some condition in asp .net

  20. 20

    asp.net repeater use template in javascript

  21. 21

    asp.net repeater merge columns dynamically

  22. 22

    Fix header row in repeater in ASP.NET

  23. 23

    ASP.NET Converting repeater item to the textbox

  24. 24

    Repeater asp.net tag not working

  25. 25

    asp.net repeater merge columns dynamically

  26. 26

    Conditional statement for Repeater Controll in ASP.NET

  27. 27

    Fix header row in repeater in ASP.NET

  28. 28

    trying Image Button in repeater Asp.net

  29. 29

    asp net dropdown selectedvalue/selectedindex not updating in repeater

HotTag

Archive