#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. [置顶] linux内核启动2-setup_arch中的内存初始化(目前分析高端内存)

    上一篇微博留下了这几个函数,现在我们来分析它们         sanity_check_meminfo();         arm_memblock_init(&meminfo, mdes ...

  2. Git超级菜鸟学习--> 社区化协作以及分支操作

    1 先将主库的url添加到本地上面, git remote add <RepoName> <URL> 2 获取主库的修改记录 git fetch --获取服务器上的修改 git ...

  3. bzoj1389

    比较有意思的一道题初看肯定是dp一类,但好像没什么思路,先令p=1-p q=1-q如果我们用常见的f[i]到第i次试验最大利润的话我们发现不好转移,因为影响因素不仅有价格,还有数量考虑到原料总量一定, ...

  4. PHP SSL Module "subjectAltNames"空字节处理安全绕过漏洞

    漏洞版本: PHP 5.3.27 PHP 5.4.17 PHP 5.5.1 漏洞描述: Bugtraq ID:61776 PHP是一种HTML内嵌式的脚本语言 PHP SSL模块不正确处理服务器SSL ...

  5. 在C#中使用WIA获取扫描仪数据(利用Filter处理图片)

    WIA Automation Layer不仅能从设备中捕获照片,还能进行简单的处理.当WIA Automation Layer从设备中捕获照片,保存为一个ImageFile对象,我们可以通过访问该Im ...

  6. JAVA中ProcessBuilder执行cmd命令找不到路径的解决方法

    今天遇到了一个很奇葩的问题,终于解决了,记一下,以做备忘. 前提条件:工程路径在D盘下 cmd要执行的可执行文件路径不在D盘下 然后...出事了............................ ...

  7. WebClient的超时问题及解决

    WebClient的超时问题及解决 转自:http://blog.163.com/xiaozhi797@126/blog/static/62440288201112245345838/   Webcl ...

  8. C++之友元函数

    1.为什么要引入友元函数:在实现类之间数据共享时,减少系统开销,提高效率 具体来说:为了使其他类的成员函数直接访问该类的私有变量 即:允许外面的类或函数去访问类的私有变量和保护变量,从而使两个类共享同 ...

  9. bzoj 1026 [SCOI2009]windy数(数位DP)

    1026: [SCOI2009]windy数 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 4550  Solved: 2039[Submit][Sta ...

  10. JavaScript高级程序设计13.pdf

    使用hasOwnProperty()方法检测一个属性存在实例还是原形中,当属性存在对象实例中时,返回true alert(person1.hasOwnProperty("name" ...