public void RemoveEmptyRows(DataTable dataTable)
{
for (int i = dataTable.Rows.Count - 1; i >= 0; i--)
{
DataRow row = dataTable.Rows[i];
bool isRowEmpty = true;
foreach (var item in row.ItemArray)
{
if (!string.IsNullOrWhiteSpace(item.ToString()))
{
isRowEmpty = false;
break;
}
}
if (isRowEmpty)
{
dataTable.Rows.RemoveAt(i);
}
}
}