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