感受DataGrid给数据操作带来的便利(6)[2]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 perky_zhou 的 blog

         //参数e用于传递列名

bindgrid(e.sortexpression);

 

}

 

如果我们要按倒序或者按顺序排序,我们可以加上“ asc 或“ desc”,如:

private void datagrid1_sortcommand(object source, system.web.ui.webcontrols.datagridsortcommandeventargs e)

{

         //参数e用于传递列名

bindgrid(e.sortexpression+" desc");

 

}

 

我们经常会有这样的需求,单击一下列标题,顺序排序,再单击一下列标题,逆序排序,下列代码来完成这样的事情:

private void datagrid1_sortcommand(object source, system.web.ui.webcontrols.datagridsortcommandeventargs e)

{

 

datagrid1.currentpageindex=0;

if(label1.text=="1")//web程序中,我喜欢用控件来保存全局变量

{

bindgrid(e.sortexpression+" desc");

label1.text="0";

}

else

{

bindgrid(e.sortexpression+" asc");

label1.text="1";

 

           }

本文关键:感受DataGrid给数据操作带来的便利(6)
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top