C# – How to display only certain columns from a data table

.netc++datagriddatasetdatatable

I'm using a web service that returns a dataset. in this dataset there are 5 table, let's say table A, B, C, D, E. I use table A.

So

DataTable dt = new DataTable()
dt = dataset.Table["A"]

Now in this datatable there are columns a1,a2,a3,a4,a5,a6,a7.

Let's say I only want to get columns a3 and a4 then bind it to my datagrid.

How do I do this?

Best Solution

Ignore the fact that you have more data than you need. Set AutoGenerateColumns to false. Create BoundColumns for a3 and a4.