修改datatable某列数据

 DataRow[] tmpDrs = null;
                                            DataTable tmpDrss = null;
                                            tmpDrs = excelData.Select(string.Format("PNO = '{0}'", Convert.ToInt32(excelData.Rows[r]["PNO"]))); //筛选数据
                                            tmpDrss = tmpDrs.CopyToDataTable();
                                            tmpDrs = tmpDrss.Select(string.Format("PNO = '{0}'", Convert.ToInt32(excelData.Rows[r]["PNO"]))); //筛选数据
                                            if (tmpDrs.Length != 0)
                                            {
                                                for (int i = 0; i < tmpDrs.Length; i++)
                                                {
                                                    DataRow dRow = tmpDrs[i];
                                                    dRow.BeginEdit(); //开始编辑
                                                    dRow["TEXT"] = SDitem.物探点号;
                                                    dRow.EndEdit(); //结束编辑
                                                    tmpDrss.AcceptChanges(); // 保存修改的结果
                                                    DataRow drcalc;
                                                    foreach (DataRow dr in tmpDrss.Rows)
                                                    {
                                                        drcalc = excelData.NewRow();
                                                        drcalc.ItemArray = dr.ItemArray;
                                                        excelData.Rows.Add(drcalc);
                                                        break;
                                                    }
                                                    break;
                                                }
                                            }

posted on 2020-07-02 14:49  林深鹿  阅读(682)  评论(0编辑  收藏  举报

导航