c# - changing Datatype of DataTable using decimal -
i comparing 2 datatables , built new table want sort values in new table since has -ve values(if not converted decimal -ve sign not considered) want convert decimal type string , return table sorting. getting error input string not in correct format how solve this?and sort -ve values in asc order
private static datatable comparetwodatatable(datatable table1, datatable table2) { datatable table3 = new datatable(); datarow dr = null; string filterexp = string.empty; (int = 0; < table1.rows.count; i++) { string col = table1.rows[i]["parameter name"].tostring(); if (table2.columns.contains(col)) { if (!table3.columns.contains(col)) { table3.columns.add(col, typeof(string)); filterexp = filterexp + col + " asc ,"; } (int j = 0; j < table2.rows.count; j++) { if (table3.rows.count != table2.rows.count) { dr = table3.newrow(); table3.rows.add(dr); } table3.rows[j][col] = (table2.rows[j][col].tostring()); } } } dataview dv = new dataview(table3); filterexp = filterexp.trimend(','); dv.sort = filterexp; table3 = dv.totable(); return table3; }
`
private static datatable comparetwodatatable(datatable table1, datatable table2) { datatable table3 = new datatable(); datarow dr = null; string filterexp = string.empty; (int = 0; < table1.rows.count; i++) { string col = table1.rows[i]["par name"].tostring(); if (table2.columns.contains(col)) { if (!table3.columns.contains(col)) { table3.columns.add(col, typeof(double)); filterexp = filterexp + col + " asc ,"; } (int j = 0; j < table2.rows.count; j++) { if (table3.rows.count != table2.rows.count) { dr = table3.newrow(); table3.rows.add(dr); } table3.rows[j][col] = table2.rows[j][col]; } } }
`
Comments
Post a Comment