Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Grouping gridview row data

Grouping gridview row data

Scheduled Pinned Locked Moved ASP.NET
helpdatabasehtmlcomperformance
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alok Sharma ji
    wrote on last edited by
    #1

    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...........

    K 1 Reply Last reply
    0
    • A Alok Sharma ji

      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...........

      K Offline
      K Offline
      KiranKumar Roy
      wrote on last edited by
      #2

      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 P

      Hope this will work for you...

      KiranKumar Roy

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups