首页 新闻 会员 周边

datagridview获取某查询条件的数量

0
[已关闭问题]
如何得到datagridview中某列="某值"的数量?<br>
apan的主页 apan | 初学一级 | 园豆:190
提问于:2008-08-24 11:35
< >
分享
其他回答(2)
0
在sql语句里面查询不可以吗
小情 | 园豆:29 (初学一级) | 2008-08-24 14:10
0
在其Rows属性中应该可以得到吧,在你的MSDN中输入下面的URL ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.chs/fxref_system.web/html/ddc88528-4d02-5dd2-c7cf-91c78e7ecfc8.htm
奇军 | 园豆:265 (菜鸟二级) | 2008-08-24 22:30
0

GetRowsCountByTargetColumn
public int GetRowsCountByTargetColumn(GridView gv, int targetColumnIndex, string targetColumnValue) {
bool ap = gv.AllowPaging;
if(ap)
gv.AllowPaging
= false;
int count = 0;
foreach(GridViewRow row in gv.Rows) {
if(row.Cells[targetColumnIndex].Text.Equals(targetColumnValue))
count
++;
}
if(ap)
gv.AllowPaging
= true;
return count;
}
使用如上方法,有问题可联系我。

陛下 | 园豆:3938 (老鸟四级) | 2008-09-07 03:38
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册