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. How to Merge a particular column in gridview using asp.net ?

How to Merge a particular column in gridview using asp.net ?

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netalgorithmstutorialquestion
9 Posts 4 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.
  • S Offline
    S Offline
    sharmila rao
    wrote on last edited by
    #1

    Please somebody post reply to this. I am a new developer, and am searching for merging rows of particular column alone.

    Thanks, Sharmi

    H E S L 4 Replies Last reply
    0
    • S sharmila rao

      Please somebody post reply to this. I am a new developer, and am searching for merging rows of particular column alone.

      Thanks, Sharmi

      H Offline
      H Offline
      Hum Dum
      wrote on last edited by
      #2

      Merge column of table (data source). you have select statement like

      Select A, B, C from tableName

      so modify it like

      Select A = A+B, C from tableName

      If you can't access select statement, then you have to modify datasource object prior setting to grid !

      S 1 Reply Last reply
      0
      • H Hum Dum

        Merge column of table (data source). you have select statement like

        Select A, B, C from tableName

        so modify it like

        Select A = A+B, C from tableName

        If you can't access select statement, then you have to modify datasource object prior setting to grid !

        S Offline
        S Offline
        sharmila rao
        wrote on last edited by
        #3

        Sorry Let me clearly ask the question again. I am binding the data from stored procedure. I must not touch the SP now. I just need to write a code in rowbound function for merging. I find only the below code in all blogs. It is merging rows of all columns in grid, i need it for only 1 column. for (int rowIndex = REGrid.Rows.Count - 2; rowIndex >= 0; rowIndex--) { GridViewRow gvRow = REGrid.Rows[rowIndex]; GridViewRow gvPreviousRow = REGrid.Rows[rowIndex + 1]; for (int cellCount = 0; cellCount < gvRow.Cells.Count; cellCount++) { if (gvRow.Cells[cellCount].Text == gvPreviousRow.Cells[cellCount].Text) { if (gvPreviousRow.Cells[cellCount].RowSpan < 2) { gvRow.Cells[cellCount].RowSpan = 2; } else { gvRow.Cells[cellCount].RowSpan = gvPreviousRow.Cells[cellCount].RowSpan + 1; } gvPreviousRow.Cells[cellCount].Visible = false; } } } This is the code. Could you please help me in this, how to re frame this loop for just 1 column. Lets assume for the first column in grid. thanks in advance

        Thanks, Sharmi

        1 Reply Last reply
        0
        • S sharmila rao

          Please somebody post reply to this. I am a new developer, and am searching for merging rows of particular column alone.

          Thanks, Sharmi

          E Offline
          E Offline
          Elham M
          wrote on last edited by
          #4

          Visit this link http://marss.co.ua/MergingCellsInGridView.aspx[^]

          S 1 Reply Last reply
          0
          • E Elham M

            Visit this link http://marss.co.ua/MergingCellsInGridView.aspx[^]

            S Offline
            S Offline
            sharmila rao
            wrote on last edited by
            #5

            Hi , I already saw that link, It is merging all columns right. I need to merge just for 1 column. I dint get it properly,the code. If possible could u pls explain each line.

            :confused:

            Thanks, Sharmi

            E 1 Reply Last reply
            0
            • S sharmila rao

              Please somebody post reply to this. I am a new developer, and am searching for merging rows of particular column alone.

              Thanks, Sharmi

              S Offline
              S Offline
              sharmila rao
              wrote on last edited by
              #6

              Friends, Please help me with this as soon as possible. By monday i need to show a demo to my Manager. Kinldy do the needful

              Thanks, Sharmi

              S 1 Reply Last reply
              0
              • S sharmila rao

                Hi , I already saw that link, It is merging all columns right. I need to merge just for 1 column. I dint get it properly,the code. If possible could u pls explain each line.

                :confused:

                Thanks, Sharmi

                E Offline
                E Offline
                Elham M
                wrote on last edited by
                #7

                so you should remove

                for

                in your perevious code and on GridView1_RowDataBound event try this code: as an example if you want to merge cells 2 of your grid

                e.Row.Cells[2].ColumnSpan=2;

                Help people is help yourself

                1 Reply Last reply
                0
                • S sharmila rao

                  Friends, Please help me with this as soon as possible. By monday i need to show a demo to my Manager. Kinldy do the needful

                  Thanks, Sharmi

                  S Offline
                  S Offline
                  sharmila rao
                  wrote on last edited by
                  #8

                  :-D I got it done myself. It is working fine now.

                  Thanks, Sharmi

                  1 Reply Last reply
                  0
                  • S sharmila rao

                    Please somebody post reply to this. I am a new developer, and am searching for merging rows of particular column alone.

                    Thanks, Sharmi

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    Hi dear you can first add column to the datatable before adding to datasource acording to the datatype

                    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