DataTable row-to-column, datatable-to-Column
/// <Summary> /// able row-to-column conversion // </summary> /// <param name = "dtable"> table to be converted </param>/ // <param name = "head"> convert the table header to the old table field (in lower case) </param> // <returns> </returns> public static DataTable DataTableRowtoCon (DataTable dtable, string head) {DataTable dt = new DataTable (); dt. columns. add ("NumberID"); for (int I = 0; I <dtable. rows. count; I ++) {// sets the header dt. columns. add (dtable. rows [I] [head]. toString ();} for (I Nt k = 0; k <dtable. columns. count; k ++) {string temcol = dtable. columns [k]. toString (); if (dtable. columns [k]. toString (). toLower ()! = Head) // filter out the columns {DataRow new_dr = dt. newRow (); new_dr [0] = dtable. columns [k]. toString (); for (int j = 0; j <dtable. rows. count; j ++) {string temp = dtable. rows [j] [k]. toString (); new_dr [j + 1] = (Object) temp;} dt. rows. add (new_dr) ;}} return dt ;}