:效果图:,aspx代码中是AllowSorting="True";,如果要修改每页条数,修改PageSize即可,在aspx代码中是PageSize="12"。,右击GridView弹出“属性”,选择AllowSorting为True即可。1:分页保存选中状态保存CheckBox的值 GridView在分页过程中并不维护CheckBox的选择状态,幸运的是,我们可以使用Session来维护CheckBox的状态,这个功能使用RememberOldValues完成privatevoidRememberOldValues(){ArrayListcategoryIDList=newArrayList();intindex=-1;foreach(){index=([].Value);boolresult=((CheckBox)("IsCheckBox")).Checked; //CheckintheSessionif(Session["state"]!=null)categoryIDList=(ArrayList)Session["state"];if(result){if(!(index))(index);}(index);}if(categoryIDList!=null&&>0)Session["state"]=categoryIDList;}还原CheckBox的状态 下一步,需要定义一个方法来还原Checkbox的状态值 privatevoidRePopulateValues(){ArrayListcategoryIDList=(ArrayList)Session["state"];if(categoryIDList!=null&&>0){foreach(){intindex=(int)[].Value;if((index)){CheckBoxmyCheckBox=(CheckBox)("IsCheckBox");=true;}}}} 最后,在分页事件里调用上面两个方法protectedvoidpage_Click(objectsender,ImageClickEventArgse){RememberOldValues();stringcount=((ImageButton)sender).().ToLower();switch(count){case"prev":if(>0){-=1;}break;case"next":if(<-1){+=1;}break;case"0":=0;break;case"last":=-1;break; }BrndOKBind();RePopulateValues();},编辑,取消,删除:效果图:后台代码:你可以使用sqlhelper,本文没用。代码如下:usingSystem;;;;;;;;;;publicpartialclass_Default:{//清清月儿http://blog./
gridview使用全套整合攻略 来自淘豆网m.daumloan.com转载请标明出处.