日期:2014-05-17 浏览次数:20635 次
/// <summary> /// 根据期望的表大小向DataTable填充空行。 /// </summary> /// <param name="dt">数据表实例。</param> /// <param name="dataTableSize">期望的数据表大小。</param> public static void FillBlankRow(DataTable dt, int dataTableSize) { if (dataTableSize < 0) throw new ArgumentOutOfRangeException("方法参数dataTableSize不能是负数。"); if (dt.Rows.Count < dataTableSize) { int additionCount = dataTableSize - dt.Rows.Count; for (int i = 0; i < additionCount; i++) { DataRow row = dt.NewRow(); dt.Rows.Add(row); } } }