Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
My Database table has 5 columns Below is my table my data.

SectionId SecName ChapterId ChapterName Duration
1 Sec1 1 Chap1 2 Days
1 Sec1 2 Chap2 2 Days
1 Sec1 3 Chap3 2 Days
2 Sec2 4 Chap4 2 Days
2 Sec2 5 Chap5 2 Days
3 Sec3 6 Chap6 1 Day
3 Sec3 7 Chap7 1 Day
4 Sec4 8 Chap8 1 Day


I want table or gridview format like below


ChapterName Duration
Sec1
Chap1 2 Days
Chap2 2 Days
Chap3 2 Days
Sec2
Chap4 2 Days
Chap5 2 Days
Sec3
Chap6 1 Day
Chap7 1 Day
Sec4
Chap8 1 Day


How can i display above format dynamically in aspx page

Thanks,
Sampath bejugama
Posted
Updated 12-Dec-11 23:45pm
v3
Comments
thatraja 13-Dec-11 5:44am    
In report?
sampath1750 13-Dec-11 7:13am    
NoIn code

1 solution

see binding time you can bind all the rows

and in your design section part you can take in DIV

XML
<div id="div1" style="text-align:center" runat="server" visible="false" >

                <%#Eval("Section")%>


                           </div>



And in code behind on ItemDataBound you can show and hide this div.IF section name changed then Show the div Other wise hide the div


VB
If (e.Item.ItemType = ListViewItemType.DataItem) Then
        Dim divCatHeader = e.Item.FindControl("divCatHeader")


VB
If Section = oldsetion Then
              divCatHeader.Visible = False

          Else
              divCatHeader.Visible = True
          End If



To find value of section you can use this in ItemDataBound

VB
If (e.Item.ItemType = ListViewItemType.DataItem) Then
          Dim x
          x = DirectCast(e.Item, ListViewItem)
          x = DirectCast(x, ListViewDataItem)
          Dim appl = DirectCast(x.dataitem, Object).Section
 
Share this answer
 
Comments
sampath1750 13-Dec-11 5:47am    
Can u give me c# code
Anuj Banka 13-Dec-11 5:49am    
friend this is an example you have to write youe code. If you want to convert this code use this link :

http://www.developerfusion.com/tools/convert/vb-to-csharp/
Anuj Banka 13-Dec-11 5:50am    
iF it help you then don't forgot to mark as ans. and upvote it :) ;)
sampath1750 13-Dec-11 7:14am    
Is this possoble in gridview

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