本文介绍了如何删除DataTable中的空行/空行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在数据表中删除空行或空行。
我的代码段
I want to Delete the Empty rows or Blank Rows in Datatable.
My Snippet
public void deleteemptyrows(DataTable dt)
{
for (int i = dt.Rows.Count; i >= 1; i--)
{
DataRow currentRow = dt.Rows[i - 1];
foreach (var col in currentRow.ItemArray)
{
if (!string.IsNullOrEmpty(col.ToString()))
break;
dt.Rows[i - 1].Delete();
}
}
}
但它不起作用
请帮我
But it is not working
pls Help Me
推荐答案
select * from Your_table where columnName !=null
然后用这个查询填充数据表。
and then fill the datatable with this query.
这篇关于如何删除DataTable中的空行/空行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!