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. How to add columns dynamically in gridview

How to add columns dynamically in gridview

Scheduled Pinned Locked Moved Web Development
tutorialquestion
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.
  • M Offline
    M Offline
    mominafiz
    wrote on last edited by
    #1

    hi, i want to add textbox columns in my Gridview dynamically. I first want to fill the gridview using dataset which i m able to...but i want to add one more extra column in the gridview at the same time. How to add that textbox column ......say on dropdownlist autopostback event or say button click event? here is the code for filling gridview using dataset

        TRcmd.CommandText = "GetLoadedTRGV"
        TRcmd.CommandType = CommandType.StoredProcedure
        TRcmd.Connection = MyTRCon
                TRcmd.Parameters.Add(New SqlParameter("@testID", SqlDbType.NVarChar) With {.Value =  testnameddl.Text})
        TRcmd.Parameters.Add(New SqlParameter("@techniqID", SqlDbType.NVarChar) With {.Value = Techniqnameddl.Text})
    
        TRadptr = New SqlDataAdapter("GetLoadedTRGV", MyTRCon)
        TRadptr.Fill(TRds)
    

    Gridview1.datsource=TRds.Tables(0)
    Gridview1.databind()

    modified on Tuesday, June 15, 2010 9:26 AM

    L 1 Reply Last reply
    0
    • M mominafiz

      hi, i want to add textbox columns in my Gridview dynamically. I first want to fill the gridview using dataset which i m able to...but i want to add one more extra column in the gridview at the same time. How to add that textbox column ......say on dropdownlist autopostback event or say button click event? here is the code for filling gridview using dataset

          TRcmd.CommandText = "GetLoadedTRGV"
          TRcmd.CommandType = CommandType.StoredProcedure
          TRcmd.Connection = MyTRCon
                  TRcmd.Parameters.Add(New SqlParameter("@testID", SqlDbType.NVarChar) With {.Value =  testnameddl.Text})
          TRcmd.Parameters.Add(New SqlParameter("@techniqID", SqlDbType.NVarChar) With {.Value = Techniqnameddl.Text})
      
          TRadptr = New SqlDataAdapter("GetLoadedTRGV", MyTRCon)
          TRadptr.Fill(TRds)
      

      Gridview1.datsource=TRds.Tables(0)
      Gridview1.databind()

      modified on Tuesday, June 15, 2010 9:26 AM

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

      I have found two nice articles regarding adding columns dynamically to GridView. how to create columns dynamically in a grid view[^] To create template bound column dynamically try this[^]. HTH

      Jinal Desai - LIVE Experience is mother of sage....

      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