Pages

Friday, September 6, 2013

Remove totally blank rows from datatable

Below code will remove totally blank rows from datatable that were fetched from excel during upload

DataTable dtStupByDate = dtStupByDate.Rows.Cast<DataRow>().Where(row => !row.ItemArray.All(field => field is System.DBNull || string.Compare((field as string).Trim(), string.Empty) == 0)).CopyToDataTable();

No comments:

Post a Comment