返回弹出窗口时,检查值应保持不变. [英] on coming back to popup check value should remain same.

查看:89
本文介绍了返回弹出窗口时,检查值应保持不变.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


在我的应用程序中,当我单击确定"弹出窗口时,选择关闭后可以选择组.我想当我再次打开该弹出窗口时,应该保持选中我选择的选项.

解决方案

您正在使用什么弹出窗口?使用JQuery UI对话框,将从页面上的div元素构造弹出窗口,除非您对其中的任何元素进行更改,否则无论刷新页面之前显示多少次,弹出窗口都将具有相同的值.



您需要遵循两个步骤.


1.在Ok_Button_Click事件上,将复选框值存储在会话中.

会话[" ] = Checkbox1.



2.在页面加载中(当弹出窗口打开时),如果会话中已经检查过值,则需要将其取回.

 If(!Page.IsPostback){

如果(会话[" ] != 为空)
{
Checkbox1.Checked = 布尔 .Parse(会话[" ].ToString());
}

       } 



希望对您有帮助


在这种情况下,您可以将确定"上的会话"中的复选框的值保存下来,然后从页面加载"中的会话"中检索它们.

这是示例代码.

在按钮上单击

 布尔 []值=   int  count =  0 ;
         for ( int  i =  0 ; i <  GridView1.Rows.Count; i ++)

        {
            chb =(CheckBox)GridView1.Rows [i] .FindControl(" );

            如果(chb!= )
            {
                values [i] = chb.Checked;
            }
        }
        会话[" ] =值; 




在页面上加载

 如果(会话["  GridValues"]!= 布尔 []值=(布尔 [])会话[ " ];

             for ( int  i =  0 ; i <  GridView1.Rows.Count; i ++)

            {
                chb =(CheckBox)GridView1.Rows [i] .FindControl(" );

                chb.Checked = values [i];
            }
        } 




让我知道它是否对您有用.

谢谢


hi,
In my application there is an option to select groups after selecting when i click on ok popup get closed. I want when i open that popup again the options which I selected should remain checked.

解决方案

What are you using for the popup? Using JQuery UI dialog the popup is constructed from a div element on your page, which unless you make a change any of the elements, will still have the same values no matter how many times it is displayed until the page is refreshed.


Hi,

You need to follow two steps.


1.On Ok_Button_Click Event Store the Checkbox Values in session.

Session["Checkbox1"]= Checkbox1.Checked



2. In Page Load ( When PopUp opens) you need need to retrieve values back If it is already checked from the session.

If(!Page.IsPostback){

if(Session["Checkbox1"]!=null)
{
Checkbox1.Checked=bool.Parse( Session["Checkbox1"].ToString());
}

       }



hope it helps


In that Case You can save the value of checkboxes in Session on Ok Click and retrieve them from Session on PageLoad


here is the example code.

on Button Click

bool[] values = new bool[GridView1.Rows.Count];

        CheckBox chb; 
        int count = 0; 
        for (int i = 0; i < GridView1.Rows.Count; i++)

        { 
            chb = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");

            if (chb != null) 
            { 
                values[i] = chb.Checked; 
            } 
        } 
        Session["GridValues"] = values; 




on Page Load

if (Session["GridValues" ] !=null) 
        { 
            CheckBox chb; 
            bool[] values = (bool[])Session["GridValues"];

            for (int i = 0; i < GridView1.Rows.Count; i++)

            { 
                chb = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");

                chb.Checked = values[i]; 
            } 
        } 




Let me know if it works for you.

Thanks


这篇关于返回弹出窗口时,检查值应保持不变.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆