I am trying to fetch table category and based on that table category the multiple details of that category will have to automatically fetch under this following category but unfortunately multiple table is created under this single category.
First of all I have created tbl_category(ID{PK}, catName) table on DB. Then created tbl_categoryDetails(ID{PK}, catId{FK}, catDetails). So I have needed multiple categoryDetails fields under single category.
So then I have to fetch this catName with their details part by part. I have attached of the static table, I need this way table data will be fetched Static Table Image.
But Unfortunately I am getting data this way My Dynamic Table Image. The categoryName fetch multiple time but I want single time. I am using repeater control to fetch data from DB. please help me to solve this problem.
My Forms.aspx code is here:
<asp:Repeater ID="rptr_form" runat="server">
<ItemTemplate>
<section class="about">
<div class="container">
<div class="row no-gutters d-flex justify-content-center">
<div class="flex-column justify-content-center about-content minwidth">
<div class="section-title">
<div class="mycontent-center">
<h2 style="margin-bottom: -5px;" data-toggle="collapse" role="button" href="#collapseExample19" aria-expanded="false" aria-controls="collapseExample19"><%#Eval("form_categoryname") %>   <i class="fa fa-chevron-circle-down" aria-hidden="true"></i></h2>
<br />
<div class="content-style collapse tbl-scroll" id="collapseExample19">
<table class="table table-striped">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">No</th>
<th scope="col">Bangla</th>
<th scope="col">English</th>
</tr>
</thead>
<tbody>
<tr class="table-info">
<td><%#Eval("form_details") %></td>
<td><%#Eval("form_no") %></td>
<td><a href="<%# "../" + Eval("form_bengali_path") %>" target="_blank">
<img src="assets/image/pdf.jpg" style="height: 30px; width: 48px;" /></a></td>
<td class="center"><a href="<%# "../" + Eval("form_english_path") %>" target="_blank">
<img src="assets/image/pdf.jpg" style="height: 30px; width: 48px;" /></a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</ItemTemplate>
</asp:Repeater>
My Forms.aspx.cs code is here:
protected void AllFormLoad()
{
try
{
using (SqlConnection con = new SqlConnection(strcon))
{
SqlCommand cmd = new SqlCommand("spFormDetailsFetch", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
rptr_form.DataSource = dt;
rptr_form.DataBind();
}
}
catch (Exception ex)
{
Response.Write("<script>alert('" + ex.Message + "');</script>");
}
}
Sql Query
select D.ID, C.form_categoryname, D.form_details, D.form_no, D.form_bengali_path, D.form_english_path from tbl_form_details D inner join tbl_form_category C on D.form_categoryId = C.ID order by form_categoryname