#region //'Revision: 1.00 Created Date: 2013/08/02 Created ID: Una [#1300071]增加多選框
/// <summary>
/// Session獲取多選框值
/// </summary>
private void RememberOldValues()
{
ArrayList categoryIDList = new ArrayList();
string index = "";
foreach (GridViewRow row in gridView.Rows)
{
index = (string)gridView.DataKeys[row.RowIndex].Value;
bool result = ((CheckBox)row.FindControl("DeleteThis")).Checked; // Check in the Session
if (Session["id"] != null)
categoryIDList = (ArrayList)Session["id"];
if (result)
{
if (!categoryIDList.Contains(index))
categoryIDList.Add(index);
}
else
categoryIDList.Remove(index);
}
if (categoryIDList != null && categoryIDList.Count > )
Session["id"] = categoryIDList;
} /// <summary>
/// Session分頁時之前多選框為true
/// </summary>
private void RePopulateValues()
{
ArrayList categoryIDList = (ArrayList)Session["id"];
if (categoryIDList != null && categoryIDList.Count > )
{
foreach (GridViewRow row in gridView.Rows)
{
string index = (string)gridView.DataKeys[row.RowIndex].Value;
if (categoryIDList.Contains(index))
{
CheckBox myCheckBox = (CheckBox)row.FindControl("DeleteThis");
myCheckBox.Checked = true;
}
}
}
}
#endregion
        protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
RememberOldValues();
gridView.PageIndex = e.NewPageIndex;
BindData();
RePopulateValues();
}
     protected void btnSelect_Click(object sender, EventArgs e)
{
string items = "";
ArrayList categoryIDList = new ArrayList();
string index ="";
foreach (GridViewRow row in gridView.Rows)
{
index = (string)gridView.DataKeys[row.RowIndex].Value;
bool result = ((CheckBox)row.FindControl("DeleteThis")).Checked; // Check in the Session
if (Session["id"] != null)
categoryIDList = (ArrayList)Session["id"];
if (result)
{
if (!categoryIDList.Contains(index))
categoryIDList.Add(index);
}
else
categoryIDList.Remove(index);
}
if (categoryIDList != null && categoryIDList.Count > )
for (int i = ; i < categoryIDList.Count; i++)
{
items += categoryIDList[i] + ",";
}
items = items.Substring(, items.Length - );
ScriptManager.RegisterStartupScript(this, this.GetType(), "", "check('" + items + "');", true);
Session.Remove("id");
}

Gridview分頁保存選項的更多相关文章

  1. ASP.NET MVC 5 實作 GridView 分頁

    本文用 ASP.NET MVC 5 實作一個 GridView,功能包括: 分頁(paging).關鍵字過濾(filtering).排序(sorting).AJAX 非同步執行,外觀上亦支援 Resp ...

  2. C# gridview分頁導出excel

    #region 导出Excel方法 //导出到Excel按钮 protected void btnExport_Click(object sender, EventArgs e) { Export(& ...

  3. thinkphp5ajax分頁&&搜索後分頁

    //控制器層 //分頁 public function list_january_table(){ //設置當前頁 $page = input("post.page") ? inp ...

  4. 使用LINQ 對List分頁/區

    listview之類的服務器控件分頁自不用多說,拖拖控件改改屬性分分鐘的事.就不浪費大家時間了.   這裏只寫大概思路及關鍵代碼了.   LINQ裏有一個對集合進行分區的操作可用於分頁.   page ...

  5. 怎樣添加設置GridView,CheckBox全選功能

    GridView內CheckBox控件全選設置 不需要添加後台代碼操作,前端即可完成設置,如下: 前端代碼: 1.設置javascript. <html xmlns="http://w ...

  6. Gridview 分多页时导出excel的解决方案

    在开发会遇到将gridview中的数据导入到excel 这样的需求,当girdview有多页数据时按照一般的方式导出的数据只可能是当前页的数据,后几页的数据还在数据库内,没有呈现到页面上,传统的方式是 ...

  7. Log4j分级别保存日志到单个文件中,并记录IP和用户信息

    <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration S ...

  8. hibernate分表保存日志

    @Service("accessLogService")@Transactionalpublic class LogMessageServiceImpl extends BaseD ...

  9. 模板列传值到子窗体中,子窗体中多选gridview中checkbox保存数据多项到数据库中

    <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> &l ...

随机推荐

  1. 【POJ3710】Christmas Game (博弈-树上的删边问题)

    [题目] Description Harry and Sally were playing games at Christmas Eve. They drew some Christmas trees ...

  2. java webservice服务器端获取request对象的三种方式

    有的时候在webservice里我们需要获取request对象和response对象,比如想要获得客户端的访问ip的时候就需要这么做,下面说三种方式,当然三种方式可能是针对不同方式部署webservi ...

  3. wcf托管在IIS上,提示未能加载

    “/”应用程序中的服务器错误. 未能加载文件或程序集“ZBMYunCoreLib.DLL”或它的某一个依赖项.找不到指定的模块. 说明: 执行当前 Web 请求期间,出现未经处理的异常.请检查堆栈跟踪 ...

  4. Invitation Cards(邻接表+逆向建图+SPFA)

    Time Limit: 8000MS   Memory Limit: 262144K Total Submissions: 17538   Accepted: 5721 Description In ...

  5. 数据结构(树状数组):HEOI2012 采花

    [题目描述] 萧薰儿是古国的公主,平时的一大爱好是采花. 今天天气晴朗,阳光明媚,公主清晨便去了皇宫中新建的花园采花.花园足够大,容纳了n朵花,花有c种颜色(用整数1-c表示),且花是排成一排的,以便 ...

  6. Python copy对象(copy与deepcopy)

    Python中的对象之间赋值时是按引用传递的,如果需要拷贝对象,需要使用标准库中的copy模块. 1. copy.copy 浅拷贝 只拷贝父对象,不会拷贝对象的内部的子对象. 2. copy.deep ...

  7. jquery 使用方式记录

    1.监听键盘事件 $("#id").keyup(function(event){ if(event.keyCode == 13){ $("#btn_addgoods_su ...

  8. ural 1106. Two Teams 二分图染色

    链接:http://acm.timus.ru/problem.aspx?space=1&num=1106 描述:有n(n<=100)个人,每个人有一个或多个朋友(朋友关系是相互的).将其 ...

  9. Linux下开启MySQL的远程连接

    今天在用客户端工具远程连接mysql的时候,连接不上,以为是防火墙,关了防火墙后依然打不开,后开在网上查了下原来mysql基于安全考虑root账户一般只能本地访问,但是在开发过程中可能需要打开root ...

  10. Codeforces Round #363 (Div. 2) 698B Fix a Tree

    D. Fix a Tree time limit per test 2 seconds memory limit per test 256 megabytes     A tree is an und ...