SQLDataReaders是仅转发的。您实际上是在这样做:
count++; // initially 1.DataBind(); //consuming all the records//next iteration on.Read()//we've now come to end of resultset, thanks to the DataBind()//count is still 1
您可以改为:
if (reader.HasRows){ rep.DataSource = reader; rep.DataBind();}int count = rep.Items.Count; //somehow count the num rows/items `rep` has.
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)