Using Repeater as A Template Column into Grid View

This is a very first time I am going to share entire project instead of Code Snippet.
During my last project, I face a requirement in which I have to display grouped data into grid, after referring various possible solutions, I decided to go with Gridview and Repeater as a Column of the grid.  Thus I can get benefits of Gridview like sorting, paging etc. easily and benefits of Repeater to show data with full flexibility.
I think this would be a useful reference for all who are going with similar kind of requirements. So please, if you like this post please share and comment.
Step 1 : I have one aspx web page and one data table as below. (In real life we can get this from database as a datatable or entity). Here I am referring through List<Entity>.



 


Roll No
Name
Percentage
Grade
101
STUDENT 1
99
A Grade
102
STUDENT 2
32
Fail
103
STUDENT 3
59
B Grade
104
STUDENT 4
46
C Grade
105
STUDENT 5
54
B Grade
106
STUDENT 6
56
B Grade
107
STUDENT 7
33
Fail
108
STUDENT 8
19
Fail
109
STUDENT 9
41
C Grade
110
STUDENT 10
99
A Grade
111
STUDENT 11
53
B Grade
112
STUDENT 12
76
A Grade
113
STUDENT 13
31
Fail
114
STUDENT 14
11
Fail
115
STUDENT 15
80
A Grade
116
STUDENT 16
23
Fail
117
STUDENT 17
50
B Grade
118
STUDENT 18
30
Fail
119
STUDENT 19
36
C Grade
120
STUDENT 20
83
A Grade
121
STUDENT 21
77
A Grade
122
STUDENT 22
36
C Grade
123
STUDENT 23
93
A Grade
124
STUDENT 24
32
Fail
125
STUDENT 25
38
C Grade
126
STUDENT 26
28
Fail
127
STUDENT 27
97
A Grade
128
STUDENT 28
65
B Grade
129
STUDENT 29
74
B Grade
130
STUDENT 30
90
A Grade


 


Step 2: Output we require is as below.


A Grade
STUDENT 1
99
STUDENT 10
99
STUDENT 12
76
STUDENT 15
80
STUDENT 20
83
STUDENT 21
77
STUDENT 23
93
STUDENT 27
97
STUDENT 30
90
B Grade
STUDENT 3
59
STUDENT 5
54
STUDENT 6
56
STUDENT 11
53
STUDENT 17
50
STUDENT 28
65
STUDENT 29
74
STUDENT 4
46
STUDENT 9
41
STUDENT 19
36
STUDENT 22
36
STUDENT 25
38
C Grage
STUDENT 4
46
STUDENT 9
41
STUDENT 19
36
STUDENT 22
36
STUDENT 25
38
Fail
STUDENT 2
32
STUDENT 7
33
STUDENT 8
19
STUDENT 13
31
STUDENT 14
11
STUDENT 16
23
STUDENT 18
30
STUDENT 24
32
STUDENT 26
28


 
Step 3: Now in our webpage we add grid and repeater controls as below.







Step 4: In Code behind we have following self-explanatory code.   

Search This Blog

Link Within Related Posts Plugin for WordPress, Blogger...