代码改变世界

DataTable删除行 循环

2010-06-02 16:07  David_Yang  阅读(517)  评论(0编辑  收藏  举报

for (int i = 0; i < count; i++)
            {
                if (Exceldt.Rows[i]["Sales Organizat"].ToString() == ""
                    || Exceldt.Rows[i]["Confirm ETD"].ToString().Trim() == "00.00.0000"
                    || Exceldt.Rows[i]["Vendor"].ToString() == "" || Exceldt.Rows[i]["Vendor Name"].ToString() == "")//判断Excel每行第一列的数据是否为空
                {
                    Exceldt.Rows.Remove(Exceldt.Rows[i]);
                    count = Exceldt.Rows.Count;
                    i = -1;

                }
            }