主页 > 知识库 > asp.net Gridview分页保存选项

asp.net Gridview分页保存选项

热门标签:电商新玩法 科大讯飞语音识别系统 电销业务 百度AI接口 网站排名优化 国美全国运营中心 人工智能 客户服务

复制代码 代码如下:

#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源码下载)

标签:益阳 POS机 南平 攀枝花 枣庄 拉萨 咸宁 厦门

巨人网络通讯声明:本文标题《asp.net Gridview分页保存选项》,本文关键词  ;如发现本文内容存在版权问题,烦请提供相关信息告之我们,我们将及时沟通与处理。本站内容系统采集于网络,涉及言论、版权与本站无关。
  • 相关文章
  • 收缩
    • 微信客服
    • 微信二维码
    • 电话咨询

    • 400-1100-266