Dev WebForm 中两个ASPxGridView之间通过过滤功能互查的解决方案

Dev WebForm 中两个ASPxGridView之间通过其中一个表的过滤功能筛选出记录然后根据表1的包含的业编号整理表2的数据并后台绑定数据前台刷新表格的解决方案:
设置两个变量:一个是总标记:zbj(整型,取值范围:0-1),一个是查询表标记:bj(取值:整型 ,可根据表的数量自行定义,如:1、2、3…)
分别在两个表的AfterPerformCallback事件写代码,首先判断总标记的值,当总标记=0时,将查询表的标记写入sql表,当总标记<>0时,不写标记。
后台代码:

 public static int bj=0;
 public static int zbj = 0;
 protected void ASPxGridView2_AfterPerformCallback(object sender, ASPxGridViewAfterPerformCallbackEventArgs e)
        {
                     
            if(zbj==0)
            {
                zbj = 1;
                string czy_str = Session["xx_user"].ToString().Trim();
                DateTime current_time = SqlHelper.fwq_datetime();

                SqlHelper.ExecuteNoneQuery("insert into 过滤标记(页面名称,操作员,操作时间,标记) values('业务查询','" + czy_str + "','" + current_time + "',2)", new SqlParameter[] { });

            }
            else
            {
                zbj = 0;
            }


            ASPxGridView grd = sender as ASPxGridView;
            int int_grd_row_count = grd.VisibleRowCount;
          
            if (int_grd_row_count > 0)
            {
                Array arr = grd.GetCurrentPageRowValues("编号").ToArray();
                Array arr2 = grd.GetCurrentPageRowValues("业编号").ToArray();
                if (arr.Length > 0)
                {
                    string flt_str = "";
                    foreach (int it in arr)
                    {
                        flt_str += "编号=" + it + " or ";
                    }
                    if (flt_str.Length > 0)
                    {
                        flt_str = flt_str.Substring(0, flt_str.Length - 4);
                    }
                    if (flt_str.Length > 0)
                    {
                        DataTable temp_dt = ywsj_dt.Select(flt_str, "").CopyToDataTable();
                        ywsj_dt = temp_dt;
                        grd.DataSource = ywsj_dt;
                        grd.DataBind();

                    }
                }


                if (arr2.Length > 0)
                {
                    string flt_str2 = "";
                    foreach (int it in arr2)
                    {
                        flt_str2 += "业编号=" + it + " or ";
                    }
                    if (flt_str2.Length > 0)
                    {
                        flt_str2 = flt_str2.Substring(0, flt_str2.Length - 4);
                    }
                    if (flt_str2.Length > 0)
                    {
                        DataTable temp_dt2 = zxsj_dt.Select(flt_str2, "").CopyToDataTable();
                        zxsj_dt = temp_dt2;
                        ASPxGridView1.DataSource = zxsj_dt;
                        ASPxGridView1.DataBind();
                    }
                }

            }
            else
            {
                ywsj_dt.Clear();
                grd.DataSource = ywsj_dt;
                grd.DataBind();


                zxsj_dt.Clear();
                ASPxGridView1.DataSource = zxsj_dt;
                ASPxGridView1.DataBind();

            }
        }

        protected void ASPxGridView1_AfterPerformCallback(object sender, ASPxGridViewAfterPerformCallbackEventArgs e)
        {

            
            ASPxGridView grd = sender as ASPxGridView;

            if (zbj == 0)
            {
                zbj = 1;
                string czy_str = Session["xx_user"].ToString().Trim();
                DateTime current_time = SqlHelper.fwq_datetime();
                SqlHelper.ExecuteNoneQuery("insert into 过滤标记(页面名称,操作员,操作时间,标记) values('业务查询','" + czy_str + "','" + current_time + "',1)", new SqlParameter[] { });

            }
            else
            {
                zbj = 0;
            }

            int int_grd_row_count = grd.VisibleRowCount;
            if (int_grd_row_count > 0)
            {

                Array arr = grd.GetCurrentPageRowValues("编号").ToArray();
                Array arr2 = grd.GetCurrentPageRowValues("业编号").ToArray();
                if (arr.Length > 0)
                {
                    string flt_str = "";
                    foreach (int it in arr)
                    {
                        flt_str += "编号=" + it + " or ";
                    }
                    if (flt_str.Length > 0)
                    {
                        flt_str = flt_str.Substring(0, flt_str.Length - 4);
                    }
                    if (flt_str.Length > 0)
                    {
                        DataTable temp_dt = zxsj_dt.Select(flt_str, "").CopyToDataTable();
                        zxsj_dt = temp_dt;
                        grd.DataSource = zxsj_dt;
                        grd.DataBind();

                    }
                }
                if (arr2.Length > 0)
                {
                    string flt_str2 = "";
                    foreach (int it in arr2)
                    {
                        flt_str2 += "业编号=" + it + " or ";
                    }
                    if (flt_str2.Length > 0)
                    {
                        flt_str2 = flt_str2.Substring(0, flt_str2.Length - 4);
                    }
                    if (flt_str2.Length > 0)
                    {
                        DataTable temp_dt2 = ywsj_dt.Select(flt_str2, "").CopyToDataTable();
                        ywsj_dt = temp_dt2;
                        ASPxGridView2.DataSource = ywsj_dt;
                        ASPxGridView2.DataBind();
                    }
                }

            }
            else
            {
                zxsj_dt.Clear();
                grd.DataSource = zxsj_dt;
                grd.DataBind();


                ywsj_dt.Clear();
                ASPxGridView2.DataSource = ywsj_dt;
                ASPxGridView2.DataBind();
            }

        }

前台代码:

 function OnEndCallback1(s, e) {
                
                $.ajax({
                    type: "post",
                    url: "/UI/Ywcx_page/ywcx.aspx/get_bj",
                    dataType: "text",
                    data: "{page_name:'业务查询'}",
                    contentType: "application/json; charset=utf-8",
                    async: false,
                    success: function (data) {
                        hh = JSON.parse(data);
                        jj = JSON.parse(hh.d);

                        var bbj = parseInt(jj[0].标记);

                        if (bbj == 1) {
                            ASPxGridView2.Refresh();
                        }
                    },
                    Error: function () {
                        alert("标记获取出错!请联系程序员!");
                    }
                });
                AdjustSize();//gridview自适应方法,可去掉
          
            }
            function OnEndCallback2(s, e) {
                $.ajax({
                    type: "post",
                    url: "/UI/Ywcx_page/ywcx.aspx/get_bj",
                    dataType: "text",
                    data: "{page_name:'业务查询'}",
                    contentType: "application/json; charset=utf-8",
                    async: false,
                    success: function (data) {
                        hh = JSON.parse(data);
                        jj = JSON.parse(hh.d);

                        var bbj =parseInt(jj[0].标记);

                        if (bbj == 2) {
                            ASPxGridView1.Refresh();
                        }
                    },
                    Error: function () {
                        alert("标记获取出错!请联系程序员!");
                    }
                });
                
                AdjustSize();//gridview自适应方法,可去掉
             
            }

我从昨天遇到一个问题,在回发过程中后台改的变量值,在前台取不到最新的值,总是在下次查询时,才会取到上一次的变量值,我本来不想将查询标记写sql表,想用全局变量或Session或HiddenField来记录查询表的标记,可是当在后台改了值后,前台总是取上一次的值,取不到最新的值,不知何故!有知道的网友可联系我!
秋风写淄博 业务联系与技术交流:QQ375172665

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值