views:

56

answers:

2

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.

A: 

Try this:

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

finalTable.AcceptChanges()

Then bind it with your gridview

Veer
I tried this..but no change..
Royson
A: 

give this a try:

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