private DataTable mergeBack(DataTable org, DataTable sorted) { sortedMap = CommonTools.DataTableToDict(sorted, 0, 2);//0,2对应相应提取的列的信息来制作字典对应。 string id; string sortedNo; DataColumn dc = new DataColumn("sortedNo", Type.GetType("System.Int16")); org.Columns.Add(dc); for (int i = 0; i < org.Rows.Count; i++) { if (org.Rows[i][0] == DBNull.Value) { continue; } id = org.Rows[i][0].ToString(); if (sortedMap.ContainsKey(id)) { sortedNo = sortedMap[id]; org.Rows[i][2] = sortedNo; } } return(org); }
private void tagChooseSorted_clicked(DataTable tb) { textBox.Text += "File loaded! "; sortedMap = CommonTools.DataTableToDict(tb); textBox.Text += "input row lines:" + tb.Rows.Count.ToString() + "\n"; }