select certain columns of a data table

后端 未结 6 692
鱼传尺愫
鱼传尺愫 2020-12-09 09:20

I have a datatable and would like to know if its possible for me to select certain columns and input the data on a table. the columns are set out as below

|col1 |col

6条回答
  •  长情又很酷
    2020-12-09 09:32

    Also we can try like this,

     string[] selectedColumns = new[] { "Column1","Column2"};
    
     DataTable dt= new DataView(fromDataTable).ToTable(false, selectedColumns);
    

提交回复
热议问题