Search code examples
c#asp.netwebformsrepeater

Nested Repeater using c# asp.net web forms


Actually I am not getting any logic using nested repeater asp.net c#.

Below is my sql Table

DocID   Title                FileAttachment                      Session
69053   s3 time table       s3 time table_UserDetails.xls        Session-3
1616    Notice              Notice_UserDetails.xls               Session-1
67792   recruiment          recruiment_UserDetails.xls           Session-2
1616    Tesing              Testing_UserDetails.xls              Session-1

I want Output like below data session wise in Nested Repeater.

  Session-1
   Notice               Notice_UserDetails.xls               Session-1
   Tesing               Testing_UserDetails.xls              Session-1
  Session-2
   recruiment           recruiment_UserDetails.xls           Session-2
  Session-3
   s3 time table        s3 time table_UserDetails.xls        Session-3

Or Any other logic to achieve above output and Session-1 should be first order by ascending Session-1, Session-2 and Session-3.


Solution

  • I would suggest to query from SQL DB with a GROUP BY on "Session" column. Then in the repeater have a custom template with the styling you need (Header of each group with Session Name).

    Find the link below for reference how to group by data and use it in Repeater. You will have to customize for your requirement. But you will get the idea how to go forward.

    http://www.dotnetcurry.com/ShowArticle.aspx?ID=206