| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1599 人关注过本帖
标题:怎样计算datagrid中显示的记录总数?
只看楼主 加入收藏
angie8
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2005-4-29
收藏
 问题点数:0 回复次数:5 
怎样计算datagrid中显示的记录总数?
怎样计算datagrid中显示的记录总数?
怎么删除datagrid中的当前行,并更新数据库?
搜索更多相关主题的帖子: datagrid中 数据库 记录 总数 删除 
2005-05-07 22:14
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
帮你顶。我也想知道

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-05-08 12:20
zhouhua617273
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2005-4-29
收藏
得分:0 
不是很清楚你要问的问题
写点东西参考以下吧
string strconn;
strconn=="server=localhost;database=(数据库名);user=sa";
SqlConnection conn=new SqlConnection(strconn);
string sqlselect="select * from 表 where id='"+txtUserNum.Text.Trim()+"'";//查询语句
//你在DataGrid里显示的是查询到的结果吧,可以用一个变量来返回查询结果的数目
SqlDataAdapter myada=new SqlDataAdapter(sqlselect,conn);
DataSet ds=new DataSet();
myada.Fill(ds,"mytable");
int count=ds.Tables["mytable"].Rows.Count;
这里count就是查询的总数目想在哪里用就用count就可以了

2005-05-22 07:03
tianhe
Rank: 1
等 级:新手上路
帖 子:86
专家分:0
注 册:2005-3-17
收藏
得分:0 
小试一下:
string connectionString= @  
"data source=localhost;Initial catalog=(数据库名);integrated security=SSPI";//连接数据库
string commandString="select  *  from 表 ";//sql 语句
SqlDataAdapter   myAdapter=new SqlDataAdapter(commandString,connectionString);//适配器即DataSet和数据源的桥梁,用于DataSet的DataTable对象和SQl语句的返回结果之间交换数据
DataSet myDataset=new DataSet();//存储数据
myAdapter.Fill(myDataset,"表");//填充数据
DataTable myTable=myDataset.Tables["表"];
int count=myTables.Rows.Count;/////////计算记录的条数
Console.WriteLine("Rows{0}",count);

-------------------------------------------- 朴素,清醒
2005-05-24 14:07
criser
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2005-9-29
收藏
得分:0 
this.dataSet11.Tables["bookinfo"].Rows.Count.ToString()
2005-10-04 18:10
唐伯猫
Rank: 8Rank: 8
等 级:贵宾
威 望:45
帖 子:5323
专家分:58
注 册:2005-8-9
收藏
得分:0 
这么多人出谋划策,究竟显示在什么地方呢?

<iframe name="alimamaifrm" frameborder="0" marginheight="0" marginwidth="0" border="0" scrolling="no" width="300" height="170" src="/go/app/tbk_app/chongzhi_300_170.php?pid=mm_28854300_2441872_11377541&page=chongzhi_300_170.php&size_w=300&size_h=170&stru_phone=1&stru_game=1&stru_travel=1" ></iframe>
2005-10-05 17:26
快速回复:怎样计算datagrid中显示的记录总数?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016870 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved