网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

asp.net如何实现Gridview分页保存选项-创新互联

小编给大家分享一下asp.net如何实现Gridview分页保存选项,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

成都网站建设哪家好,找创新互联公司!专注于网页设计、网站建设、微信开发、成都小程序开发、集团成都定制网站等服务项目。核心团队均拥有互联网行业多年经验,服务众多知名企业客户;涵盖的客户类型包括:成都岗亭等众多领域,积累了大量丰富的经验,同时也获得了客户的一致赞赏!

代码如下:



#region //'Revision: 1.00 Created Date: 2013/08/02 Created ID: Una [#1300071]增加多選框
        ///


        /// Session獲取多選框值
        ///

        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;
        }

        ///


        /// Session分頁時之前多選框為true
        ///

        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");
        }


以上是“asp.net如何实现Gridview分页保存选项”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!


当前名称:asp.net如何实现Gridview分页保存选项-创新互联
网页网址:http://bjjierui.cn/article/dgeeje.html

其他资讯