Shaitan00 Posted September 11, 2005 Posted September 11, 2005 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, Quote
bri189a Posted September 11, 2005 Posted September 11, 2005 Actually it's quite easy to remove a column from a DataGrid if your talking ASP.NET - windows, don't 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, don't 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). Quote
Shaitan00 Posted September 11, 2005 Author Posted September 11, 2005 There is no DataGrid.Columns in C# that I can see. Quote
penfold69 Posted September 12, 2005 Posted September 12, 2005 Create a DataGridTableStyle that only includes the relevant columns that you wish to display B. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.