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 add dynamic coulmn in Gridview & its value.?

How to add dynamic coulmn in Gridview & its value.?

Scheduled Pinned Locked Moved ASP.NET
helptutorialquestion
5 Posts 3 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.
  • G Offline
    G Offline
    GroCareer
    wrote on last edited by
    #1

    Hi My Gridview is displaying data as. SN ID 1 C120 2 C121 3 C124 4 C121 5 C128 6 C120 7 C121 when i click on one button this above grdview is displayed .my dataset is returning these 2 values. I want to display Count column in Gridview as SN ID Count 1 C120 1 2 C121 1 3 C124 1 4 C121 2 5 C128 1 6 C120 2 7 C121 3 if ID e.g in above gridview C120 is repeating 2 times & C121 is repeating 3 times.So I want to display as above shown Count . Please help How i do this. Thnx GroCareer

    C H 2 Replies Last reply
    0
    • G GroCareer

      Hi My Gridview is displaying data as. SN ID 1 C120 2 C121 3 C124 4 C121 5 C128 6 C120 7 C121 when i click on one button this above grdview is displayed .my dataset is returning these 2 values. I want to display Count column in Gridview as SN ID Count 1 C120 1 2 C121 1 3 C124 1 4 C121 2 5 C128 1 6 C120 2 7 C121 3 if ID e.g in above gridview C120 is repeating 2 times & C121 is repeating 3 times.So I want to display as above shown Count . Please help How i do this. Thnx GroCareer

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      write your SQL so it returns this extra column, then bind to it. Always the easiest way. you could just add the column and use code to set the values, but why not do it in the DB?

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      G 1 Reply Last reply
      0
      • C Christian Graus

        write your SQL so it returns this extra column, then bind to it. Always the easiest way. you could just add the column and use code to set the values, but why not do it in the DB?

        Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        G Offline
        G Offline
        GroCareer
        wrote on last edited by
        #3

        How to calculate Count's value in SQL. Please help how to write query for this. Thx Grocareer

        C 1 Reply Last reply
        0
        • G GroCareer

          How to calculate Count's value in SQL. Please help how to write query for this. Thx Grocareer

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          It could be an expensive query, I'm thinking you need to ask for the count of items with the same Id, whose row number is less than the current one.

          Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          1 Reply Last reply
          0
          • G GroCareer

            Hi My Gridview is displaying data as. SN ID 1 C120 2 C121 3 C124 4 C121 5 C128 6 C120 7 C121 when i click on one button this above grdview is displayed .my dataset is returning these 2 values. I want to display Count column in Gridview as SN ID Count 1 C120 1 2 C121 1 3 C124 1 4 C121 2 5 C128 1 6 C120 2 7 C121 3 if ID e.g in above gridview C120 is repeating 2 times & C121 is repeating 3 times.So I want to display as above shown Count . Please help How i do this. Thnx GroCareer

            H Offline
            H Offline
            Harini N K
            wrote on last edited by
            #5

            Hi I have answered the same question in SQL / ADO / ADO.Net Try this: SELECT SNO, Id, ( SELECT (COUNT(*) + 1) FROM table1 b WHERE b.SNO < a.SNO AND a.Id = b.Id) FROM table1 a OR SELECT SNO, Id, ( SELECT COUNT(*) FROM table1 b WHERE b.SNO <= a.SNO AND a.Id = b.Id) FROM table1 a

            Harini

            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