后台代码
/// <summary>
/// 获取datatable前几条数据/// </summary>
/// <param name="TopItem"></param>
/// <param name="oDT"></param>
/// <returns></returns>
public static DataTable DtSelectTop(int TopItem, DataTable oDT)
{
if (oDT.Rows.Count < TopItem) return oDT;
DataTable NewTable = oDT.Clone();
DataRow[] rows = oDT.Select("1=1");
for (int i = 0; i < TopItem; i++)
{
NewTable.ImportRow((DataRow)rows[i]);
}
return NewTable;
}
//取bjxxdt的前7条数据
调用 repeater4.DataSource = DtSelectTop(7, bjxxDt);