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. Trying to hide specific columns in a datagrid populated by a datatable...mappingtype.hidden not working... HELP

Trying to hide specific columns in a datagrid populated by a datatable...mappingtype.hidden not working... HELP

Scheduled Pinned Locked Moved ASP.NET
helpworkspace
1 Posts 1 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.
  • C Offline
    C Offline
    cavall
    wrote on last edited by
    #1

    This is my code to fill a dataset with a table... fill the datatable with that table, then hide columns in the table based on a user selected criteria in a dropdown list. I have unchecked remove columns at runtime and setup all the bound columns, but ALL of the columns still are showing instead of just the ones that are not hidden. Any help appreciated... Thanks Dim dt As DataTable da.Fill(ds, "CAPdetails") dt = ds.Tables("CAPdetails") conn.Close() Dim x As Integer Select Case drpLocation.SelectedItem.Value Case "Ankeny", "Rockford", "Green Bay" 'Only shows Carson numbers For x = 0 To (dt.Columns.Count - 1) If dt.Columns(x).ColumnName.Substring(0, 4) <> "Cars" Then dt.Columns(x).ColumnMapping = MappingType.Hidden End If Next Case "Aberdeen", "Ontario" 'Only shows FullLine and Off5th numbers For x = 0 To (dt.Columns.Count - 1) If dt.Columns(x).ColumnName.Substring(0, 4) <> "Full" Or dt.Columns(x).ColumnName.Substring(0, 4) <> "Off5" Then dt.Columns(x).ColumnMapping = MappingType.Hidden End If Next Case "Steele" 'Only shows Proffitts and Parisian numbers For x = 0 To (dt.Columns.Count - 1) If dt.Columns(x).ColumnName.Substring(0, 4) <> "Prof" Or dt.Columns(x).ColumnName.Substring(0, 4) <> "Pari" Then dt.Columns(x).ColumnMapping = MappingType.Hidden End If Next End Select dgCAPdetail.DataSource = dt dgCAPdetail.DataBind() dgCAPdetail.Visible = True "Nothing is at last sacred, but the integrity of your own mind." "What lies behind us and what lies before us are nothing compared to what lies within us." - Ralph Waldo Emerson

    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