Grouping gridview row data
-
hi friends, i have a very specific need for my new project and even logical explanation will do the job :). I want to show repeated gridview data in a column with seperated commas and i am also using onrowcreated and rowdatabound methods for multiple headers of gridview from this example: http://www.dotnettwitter.com/2010/12/how-to-create-multiple-row-header-and.html[^] i also tried grouped gridview example from here: GroupedGridview - A Customized GridView Control[^] but this doesnt fix my needs as i want data like this: database fields/values from query: Column_groupid | Group_users | designation | Period 58 Matt Admin 5 58 Andrew Admin 5 58 Sachin Admin 5 58 Dinesh Admin 5 59 Sara SuperAdmin 2 59 John SuperAdmin 2 as you can see the name field is changing while others are distinct (which may change but not an issue for now); now i want to display the data in gridview as: Sr_no | Group_Persons | designation | Period 1 Matt, Andrew, Admin 5 Sachin, Dinesh 2 Sara,John SuperAdmin 2 how can i solve this problem currently i am thinking of using list and filling it in asp:table but i am afraid of performance issues. thanks & Regards Alok Sharma
Once their was a rumor, then it became reality...........
-
hi friends, i have a very specific need for my new project and even logical explanation will do the job :). I want to show repeated gridview data in a column with seperated commas and i am also using onrowcreated and rowdatabound methods for multiple headers of gridview from this example: http://www.dotnettwitter.com/2010/12/how-to-create-multiple-row-header-and.html[^] i also tried grouped gridview example from here: GroupedGridview - A Customized GridView Control[^] but this doesnt fix my needs as i want data like this: database fields/values from query: Column_groupid | Group_users | designation | Period 58 Matt Admin 5 58 Andrew Admin 5 58 Sachin Admin 5 58 Dinesh Admin 5 59 Sara SuperAdmin 2 59 John SuperAdmin 2 as you can see the name field is changing while others are distinct (which may change but not an issue for now); now i want to display the data in gridview as: Sr_no | Group_Persons | designation | Period 1 Matt, Andrew, Admin 5 Sachin, Dinesh 2 Sara,John SuperAdmin 2 how can i solve this problem currently i am thinking of using list and filling it in asp:table but i am afraid of performance issues. thanks & Regards Alok Sharma
Once their was a rumor, then it became reality...........
Hello, I really dont know this will help you or not.. But still i want to give my try.. you can try to get your solution by sql query.. Below to create test table
CREATE TABLE [ForTest](
[id] [int] NULL,
[id2] [int] NULL,
[vak] [varchar](50) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
INSERT [dbo].[ForTest] ([id], [id2], [vak]) VALUES (1, 1, N'abc')
INSERT [dbo].[ForTest] ([id], [id2], [vak]) VALUES (1, 1, N'xyz')
INSERT [dbo].[ForTest] ([id], [id2], [vak]) VALUES (2, 2, N'pqr')
INSERT [dbo].[ForTest] ([id], [id2], [vak]) VALUES (2, 2, N'mno')and below query to get result as per you wish..
SELECT
distinct P.id,
STUFF
(
(
SELECT ',' + vak
FROM ForTest M
WHERE M.id = P.id
ORDER BY id
FOR XML PATH('')
), 1, 1, ''
) AS Models
FROM
ForTest PHope this will work for you...
KiranKumar Roy