csharp Remove Empty rows in datatable

简介: //20120803 Geovin Du //塗聚文 締友計算機信息技術有限公司 DataTable dt = new DataTable(); dt=agreementMonthlySalaryListBLL.SelectImportExceltoDataGridView(file
//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);

目录
相关文章
|
6月前
|
开发者 Python
【Python】已解决:TypeError: descriptor ‘index‘ for ‘list‘ objects doesn‘t apply to a ‘str‘ object
【Python】已解决:TypeError: descriptor ‘index‘ for ‘list‘ objects doesn‘t apply to a ‘str‘ object
164 0
|
7月前
Each child in a list should have a unique “key“ prop. Check the render method的报错解决
Each child in a list should have a unique “key“ prop. Check the render method的报错解决
|
7月前
|
Python
【已解决】AttributeError: ‘Index‘ object has no attribute ‘to_list‘
【已解决】AttributeError: ‘Index‘ object has no attribute ‘to_list‘
SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘thinkphp.test‘ don‘t exsit
SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘thinkphp.test‘ don‘t exsit
391 0
AttributeError: ‘set‘ object has no attribute ‘items‘
出现这个问题,原因可能是定义的header有问题
196 0
|
Python
You are trying to merge on object and int64 columns. If you wish to proceed you should use pd.conca
You are trying to merge on object and int64 columns. If you wish to proceed you should use pd.conca
804 0
成功解决AttributeError: ‘dict_values‘ object has no attribute ‘index‘
成功解决AttributeError: ‘dict_values‘ object has no attribute ‘index‘
成功解决AttributeError: 'MapDataset' object has no attribute 'group_by_window'
成功解决AttributeError: 'MapDataset' object has no attribute 'group_by_window'
成功解决AttributeError: 'MapDataset' object has no attribute 'group_by_window'
|
SQL Java 数据库连接
JPA异常:Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
JPA异常:Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
2128 0
|
Java
错误Batch update returned unexpected row count from update [0]; actual row count: 0;
错误Batch update returned unexpected row count from update [0]; actual row count: 0;   把开发过程中碰到的BUG累积下来也是一笔财富。
3743 0
错误Batch update returned unexpected row count from update [0]; actual row count: 0;

热门文章

最新文章