Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
i m using Bootstrap collapse with asp.net c#. i want to print data from database in collapse format.

Database

Course_id | Course_Name | Course_Category
1 | MS Word | Computer Course
2 | MS Excel | Computer Course
3 | MS Powepoint| Computer Course
4 | VMWARE | Computer Course
5 | PHP | Computer Course
6 | ASP.NET | Computer Course
7 | Auditing | Accounts
8 | Accounts | Accounts
9 | Tally | Accounts
10 | Assets | Accounts


I Want to show Like this using bootstrap coolapse

Computer Course

- MS Word
- MS Excel
- MS Powepoint
- VMWARE
- PHP
- ASP.NET

Accounts

- Auditing
- Accounts
- Tally
- Assets

<div class="panel-group">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <asp:Repeater ID="Repeater2" runat="server">
                            <HeaderTemplate>
                                <h4 class="panel-title">
                                    <a data-toggle="collapse" href="#collapse<%# Container.ItemIndex + 1 %>">
                                        <asp:Literal ID="Literal1" runat="server"></asp:Literal></a>
                                </h4>
                                </div>
                            <div id="collapse<%# Container.ItemIndex + 1 %>" class="panel-collapse collapse">
                                <div class="panel-body">
                                    <div class="list-group">
                            </HeaderTemplate>
                            <ItemTemplate>
                                <a class="list-group-item" href="/KB/answers/StudentCourseDetails.aspx"?C=<%# Eval("Course") %>"><%# Container.ItemIndex + 1 %> <%# Eval("Course_Name") %></a>
                            </ItemTemplate>
                            <FooterTemplate>
                                </div>
                            </div>
                            </div>
                            </FooterTemplate>
                        </asp:Repeater>
                    </div>
                </div>
            </div>


What I have tried:

c# Code :

protected void GetCourses()
{
DT = BLL.GetDistinctCourseName();
if (DT.Rows.Count > 0)
{
Repeater2.DataSource = DT;
Repeater2.DataBind();
for (int a = 0; a < DT.Rows.Count; a++)
{
Literal Literal1 = Repeater2.Controls[0].Controls[0].FindControl("Literal1") as Literal;
Literal1.Text = DT.Rows[a]["Course_Cat"].ToString();
}
}
}
Posted
Comments
Sinisa Hajnal 19-Feb-16 8:42am    
Use RepeaterItemDataBound event and bind the data there (or Eval like you're using above). Remove literals, put "real" controls that you can set properties to (such as label) - set course name as label text

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900