Adyt Adyt - 19 days ago 4
C# Question

How do I display only certain columns from a data table?

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.


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?


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