Reputation: 2901
I want to delete specific column from my datable before bounding it to a grid view. I tried with
finalTable.Columns.RemoveAt(0);
finalTable.Columns.RemoveAt(1);
but it does not delete rows values belonging to that column..
How can we delete column with row values??
EDIT: After bounding it to gridview rows are displayed in 3rd column.
Upvotes: 2
Views: 1547
Reputation: 4555
give this a try:
DataTable example;
example.Columns.Remove("columnName");
example.Columns.RemoveAt(columnIndex);
Upvotes: 1
Reputation: 12934
Try this:
If(finalTable.Columns.CanRemove(finalTable.Columns[0]))
{
finalTable.Columns.RemoveAt(0);
}
finalTable.AcceptChanges()
Then bind it with your gridview
Upvotes: 0