Delete Columns from DataSet for Datagrid Viewing purposes [C#]

Shaitan00

Well-known member
Joined
Aug 11, 2003
Messages
343
Location
Hell
Given a DataSet [ds] that will be used to populate a DataGrid [dgTasks] as DataSource which has the following format:
ds.Tables[0]:
[CLIENT] [ASSIGNMENT] [ELAPSED TIME] [FORMATTED ELAPSED]
Client1 Assignment1 150 XX:XX:XX
Client1 Assignment2 500 XX:XX:XX
Client2 Assignment1 456009 XX:XX:XX

In my DataGrid [dgTasks] I want to display the columns [CLIENT], [ASSIGNMENT], and [FORMATTED ELAPSED] therefore omitting the [ELAPSED TIME] column that was used to generate the [FORMATTED ELAPSED] column.
Now if I rememeber correctly it is very difficult to hide a column once the dataset it attached (datasource) to the Datagrid - so I thought of a good solution, delete the column [ELAPSED TIME] after I am done generating the [FORMATTED ELASPED] column.
So - question is simple - either how do I delete an entire column from a DataSet or if anyone has any other suggestions to resolve my dilemna. Thanks,
 
Actually its quite easy to remove a column from a DataGrid if your talking ASP.NET - windows, dont know - but probably similiar:

this.dataGrid1.Columns[x].Visible = false;

where x is the column you want to hide.

Or if the windows control supports it, dont use that column as one of the columns to bind to (ASP supports that, so I imagine in some facit the windows version of the control does too).
 
Back
Top