• 企业400电话
  • 微网小程序
  • AI电话机器人
  • 电商代运营
  • 全 部 栏 目

    企业400电话 网络优化推广 AI电话机器人 呼叫中心 网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    asp.net Gridview分页保存选项

    复制代码 代码如下:

    #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 > 0)
                    Session["id"] = categoryIDList;
            }

            /// summary>
            /// Session分頁時之前多選框為true
            /// /summary>
            private void RePopulateValues()
            {
                ArrayList categoryIDList = (ArrayList)Session["id"];
                if (categoryIDList != null categoryIDList.Count > 0)
                {
                    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 > 0)
                    for (int i = 0; i categoryIDList.Count; i++)
                    {
                        items += categoryIDList[i] + ",";
                    }
                items = items.Substring(0, items.Length - 1);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "", "check('" + items + "');", true);
                Session.Remove("id");
            }

    您可能感兴趣的文章:
    • GridView分页的实现以及自定义分页样式功能实例
    • GridView自定义分页的四种存储过程
    • C#自定义DataGridViewColumn显示TreeView
    • yii2.0之GridView自定义按钮和链接用法
    • GridView自定义删除操作的具体方法
    • 自定义GridView并且实现拖拽(附源码)
    • asp.net gridview自定义value值的代码
    • asp.net gridview分页:第一页 下一页 1 2 3 4 上一页 最末页
    • asp.net中的GridView分页问题
    • Android入门之ActivityGroup+GridView实现Tab分页标签的方法
    • 基于GridView和ActivityGroup实现的TAB分页(附源码)
    • GridView自定义分页实例详解(附demo源码下载)
    上一篇:vs2010根据字符串内容添加断点的方法介绍
    下一篇:微软ajax库的使用方法(ajax.ajaxMethod)
  • 相关文章
  • 

    © 2016-2020 巨人网络通讯 版权所有

    《增值电信业务经营许可证》 苏ICP备15040257号-8

    asp.net Gridview分页保存选项 asp.net,Gridview,分页,保存,