#region 获取DataTable前几条数据
        /// <summary>
        /// 获取DataTable前几条数据
        /// </summary>
        /// <param name="TopItem">前N条数据</param>
        /// <param name="oDT">源DataTable</param>
        /// <returns></returns>
        public static DataTable DtSelectTop(int TopItem, DataTable dt1)
        {
            if (dt1.Rows.Count < TopItem) return dt1;

            DataTable NewTable = dt1.Clone();
            DataRow[] rows = dt1.Select("1=1");
            for (int i = 0; i < TopItem; i++)
            {
                NewTable.ImportRow((DataRow)rows[i]);
            }
            return NewTable;
        }
        #endregion

 

posted on 2018-10-08 10:09  蒙蒙浮霁月  阅读(209)  评论(0编辑  收藏  举报