/// <summary> /// 按前臺分頁樣式為datatable增加空行 /// </summary> /// <param name="gridPageSize">grid分頁行數</param> /// <param name="dt"></param> /// <returns></re ...
/// <summary> /// 按前臺分頁樣式為datatable增加空行 /// </summary> /// <param name="gridPageSize">grid分頁行數</param> /// <param name="dt"></param> /// <returns></returns> public static DataTable FitDatatableRows(int gridPageSize, DataTable dt) { int needAddCount = 0; //需要添加的行數 int remainder = dt.Rows.Count % gridPageSize;//取餘數 //當dt為空 或不是分頁行數的整數倍時 if (dt.Rows.Count > 0 && remainder != 0 || dt.Rows.Count == 0) { needAddCount = gridPageSize - remainder; } for (int i = 0; i < needAddCount; i++) { dt.Rows.Add(new object[] { }); dt.AcceptChanges(); } return dt; }