逐层循环删除

if (dt != null)
            {
                int count = dt.Rows.Count;

                for (int i = count - 1; i >= 0; i--)
                {
                    DataTable dt2 = bn.GetNewsListByType(dt.Rows[i]["NeTy_Id"].ToString());
                    if (dt2 != null)
                    {
                        int count2 = dt2.Rows.Count;

                        for (int j = count2 - 1; j >= 0; j--)
                        {
                           bn.DelNews( dt2.Rows[j]["Ne_Id"].ToString());
                         }
                    }
                  bn.DelNewsType( dt.Rows[i]["NeTy_Id"].ToString()) ;
                }
            }

原文地址:https://www.cnblogs.com/ken-admin/p/5826382.html