none
Is there a better way to get subtable with selected columns of a datatable? RRS feed

  • General discussion

  • Hi, I know that DataTable.Select() does not support column filter. So far, what I can do to get subtable of a DataTable is to make a loop and add rows to a new DataTable. Is there a better way to do so? Or tell me what is your choice when facing this problem? Thx.

    Saturday, December 26, 2009 7:49 AM

All replies

  • Hi, I just refer to MSDN and find a probably better way:
    1. Create a DataView of the source DataTabel;
    2. Use the DataView.ToTable(bool, string[]) or DataVidw.ToTable(string, bool, string[]) to Get the subtable, noting that string[] specifies which colomns are included.

    I think this should be the right answer.
    Saturday, December 26, 2009 7:59 AM