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. Grid View Column

Grid View Column

Scheduled Pinned Locked Moved ASP.NET
cssquestion
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.
  • S Offline
    S Offline
    Senseicads
    wrote on last edited by
    #1

    I have a gridview that is populated via a datatable. What I am wanting to do is take the raw data from the datatable and create a set of bound columns and populate those columns with the values in the datatable. my code currently is as follows. Dim datValTable As DataTable ' Create a dataTable to populate with the data Returned from the select statement. Dim datTable As DataTable datTable = New DataTable("ViewTable") datTable = PopulateDrillDown(datTable) GridView1.DataSource = datTable GridView1.DataBind() GridView1.Columns.Clear() Dim bFld As BoundField = Nothing bFld = New BoundField() bFld.DataField = "view_id" bFld.HeaderText = "ViewID" GridView1.Columns.Add(bFld) GridView1.DataBind() This adds the ViewID column to all the columns from the datatable. which is obv not what i want. I need to be able to create a subset of columns from the datatable and populate my gridview with that. Can anyone point me in the right direction. Do i need to create a new datatable and populate that then bind on the gridview? Cheers Ian

    F 1 Reply Last reply
    0
    • S Senseicads

      I have a gridview that is populated via a datatable. What I am wanting to do is take the raw data from the datatable and create a set of bound columns and populate those columns with the values in the datatable. my code currently is as follows. Dim datValTable As DataTable ' Create a dataTable to populate with the data Returned from the select statement. Dim datTable As DataTable datTable = New DataTable("ViewTable") datTable = PopulateDrillDown(datTable) GridView1.DataSource = datTable GridView1.DataBind() GridView1.Columns.Clear() Dim bFld As BoundField = Nothing bFld = New BoundField() bFld.DataField = "view_id" bFld.HeaderText = "ViewID" GridView1.Columns.Add(bFld) GridView1.DataBind() This adds the ViewID column to all the columns from the datatable. which is obv not what i want. I need to be able to create a subset of columns from the datatable and populate my gridview with that. Can anyone point me in the right direction. Do i need to create a new datatable and populate that then bind on the gridview? Cheers Ian

      F Offline
      F Offline
      Fred_Smith
      wrote on last edited by
      #2

      Why not just return the columns you want in the first place? However, if you insist... you could either set the appropriate columns' width to zero, or else create a dataview with the columns you want out of the datatable and simply bind the datatable to that - there is no need to bind it to the datatable at all. Fred

      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