Removing columns with row values ​​from a data table

I want to remove a specific column from my datable before limiting it to the grid view. I tried with

finalTable.Columns.RemoveAt(0);
finalTable.Columns.RemoveAt(1);

      

but it does not delete the row values ​​that belong to that column.

How can I delete a column with row values?

EDIT: After it's anchored to the grid, the rows are displayed in the third column.

+2


a source to share


2 answers


try:



 DataTable example; 
       example.Columns.Remove("columnName"); 
       example.Columns.RemoveAt(columnIndex); 

      

+1


a source


Try the following:

If(finalTable.Columns.CanRemove(finalTable.Columns[0]))
{
    finalTable.Columns.RemoveAt(0); 
}

finalTable.AcceptChanges()

      



Then bind it using gridview

0


a source







All Articles