//20120803 Geovin Du
//塗聚文 締友計算機信息技術有限公司
DataTable dt = new DataTable();
dt=agreementMonthlySalaryListBLL.SelectImportExceltoDataGridView(fileUrl, sheet).Copy();
if ((dt != null) && (dt.Rows != null) && (dt.Rows.Count > 0))
{
List<System.Data.DataRow> removeRowIndex = new List<System.Data.DataRow>();
int RowCounter = 0;
foreach (System.Data.DataRow dRow in dt.Rows)
{
for (int index = 0; index < dt.Columns.Count; index++)
{
if (dRow[index] == DBNull.Value)
{
removeRowIndex.Add(dRow);
break;
}
else if (string.IsNullOrEmpty(dRow[index].ToString().Trim()))
{
removeRowIndex.Add(dRow);
break;
}
}
RowCounter++;
}
// Remove all blank of in-valid rows
foreach (System.Data.DataRow rowIndex in removeRowIndex)
{
dt.Rows.Remove(rowIndex);
}
}
dataGridView1.DataSource = null;
set.SetDataGridViewBindingSourceNavigatorBinds(dataGridView1,dt , bindingSource1, bindingNavigator1);
csharp Remove Empty rows in datatable
最新推荐文章于 2022-12-23 16:58:08 发布