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



绑定,翻页


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


绑定,翻页
发表于:2007-01-18 16:38:28 楼主
private   void   binddata(bool   bl)
{
sqlconnection   conn   =   new   sqlconnection();
string   connstr   =   "integrated   security   =   sspi;data   source   =lw;initial   catalog   =   test;   user   id   =   sa;password   = ' ' ";
conn.connectionstring=connstr;
conn.open();

string   sqlstr   =   "select   *   from   xue_sheng ";
sqldataadapter   da   =   new   sqldataadapter(sqlstr,conn);
                       
dataset   ds   =   new   dataset( "ds ");

datatable   dt   =   new   datatable();

da.fill(ds, "xue_sheng ");

dt   =   ds.tables[0];

dg.datasource=dt;
dg.databind();

yeshu.text=   this.dg.pagecount.tostring();
dangqianye.text=   convert.tostring(this.dg.currentpageindex   +1);
                        recordpcount.text   =   dt.rows.count.tostring();  
dl.selectedvalue     =   convert.tostring(dg.currentpageindex   +   1);
listitem   item;
dl.items.clear();
for(int   i=1;i <dg.pagecount+1;i++)
{
item   =   new   listitem(i.tostring(),i.tostring());
dl.items.add(item);
}

dl.selectedvalue     =   convert.tostring(dg.currentpageindex   +   1);



}


private   void   dl_selectedindexchanged(object   sender,   system.eventargs   e)
{

int   index   =   convert.toint32(dl.selectedvalue);
dg.currentpageindex   =   index-1;  
binddata(false);
}


快速检索

最新资讯
热门点击