您的位置:程序门 -> .net技术 -> c#



分页控件绑定


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


分页控件绑定
发表于:2007-09-07 09:13:31 楼主
protected   void   bindgrid()
{
sqlcon   =   new   sqlconnection(strcon);
//定义sql语句
string   acsql= "select   *   from   dbo.tb_factory ";
sqlcon.open();
//定义数据适配器
sqldataadapter   acda=new   sqldataadapter(acsql,strcon);
//创建数据集
dataset   acds=new   dataset();
//从指定的索引开始取pagesize条记录
acda.fill(acds,haha.pagesize*(haha.currentpageindex-1),haha.pagesize, "curdatatable ");
//创建所有数集
acda.fill(acds, "alldatatable ");
//设置datagrid控件实际显示的项数
sqlcon.close();
datagrid1.virtualitemcount=acds.tables[ "alldatatable "].rows.count;
//数据绑定
datagrid1.datasource=acds.tables[ "curdatatable "];
datagrid1.databind();
haha.custominfotext= "   共有留言 <font   color=\ "blue\ "> <b> "+haha.recordcount.tostring()+ " </b> </font> 条 ";
haha.custominfotext+= "   共有 <font   color=\ "blue\ "> <b> "+haha.pagecount.tostring()+ " </b> </font> 页 ";
haha.custominfotext+= "   当前为第 <font   color=\ "red\ "> <b> "+haha.currentpageindex.tostring()+ " </b> </font> 页 ";
acda.dispose();
this.close();

}

alldatatable   curdatatable是什么意思


快速检索

最新资讯
热门点击