GridView控制項自帶排序 一

2021-05-21 10:26:58 字數 1690 閱讀 5575

1 using system;

2 using system.data;

3 using system.data.sqlclient;

4 using system.configuration;

5 using system.collections;

6 using system.web;

7 using system.web.security;

8 using system.web.ui;

9 using system.web.ui.webcontrols;

10 using system.web.ui.webcontrols.webparts;

11 using system.web.ui.htmlcontrols;

12 13 public partial class demo6 : system.web.ui.page

14 24     }

25 26     public void binddata()

27     ", sortexpression, sortdirection);

38         }

39 40         gridview.datasource = dt;

41         gridview.databind();

42     }

43 44     protected void gridview_pageindexchanging(object sender, gridviewpageeventargs e)

45    

49 50     protected void gridview_sorting(object sender, gridviewsorteventargs e)

51    

62         // 重新設定gridview排序資料列及排序方向

63         this.gridview.attributes["sortexpression"] = sortexpression;

64         this.gridview.attributes["sortdirection"] = sortdirection;

65         binddata();

66 67     }

68 }

69 70

1 2        

3            

4                 gridview演示

5        

6       

7           

8              

9                

10                      

11                      

12                      

13                      

14                  

15                  

16                  

17              

18           

19       

20      

21       

22

GridView 自帶分頁

用三層做的。一 model using system using system.collections.generic using system.linq using system.text namespace model public string sname public string gend...

擴充套件 GridView 控制項

解決 方法一 採用其emptytemplate來實現,模版中寫乙個靜態的table 缺點 麻煩,每個gridview都需要設定一下.方法二 若資料來源為datatable,則當無資料時,始終返回乙個空行的datatable 若資料來源是集合類 arraylist,list等 無資料時,生成乙個空的實...

gridView分頁控制項

using system using system.collections.generic using system.linq using system.web using system.web.ui.webcontrols using system.drawing using system.tex...