用户控件里有单选按钮  如果我用new的话 得到的不是我当前所操作单选按钮的值了 请问怎么能调用出当前选择的值呢

解决方案 »

  1.   

    没办法额
     public   void RecordQuestions()
            {
                try
                {
                    string haveanswer = "";
                    if (panR.Visible == true)
                    {
                        if (rdbA.Checked == true) { haveanswer = "A"; }
                        else if (rdbB.Checked == true) { haveanswer = "B"; }
                        else if (rdbC.Checked == true) { haveanswer = "C"; }
                        else if (rdbD.Checked == true) { haveanswer = "D"; }
                        else if (rdbE.Checked == true) { haveanswer = "E"; }
                    }
                    else if (panC.Visible == true)
                    {
                        if (cboA.Checked == true) { haveanswer += "A"; }
                        if (cboB.Checked == true) { haveanswer += "B"; }
                        if (cboC.Checked == true) { haveanswer += "C"; }
                        if (cboD.Checked == true) { haveanswer += "D"; }
                        if (cboE.Checked == true) { haveanswer += "E"; }
                    }
                    else if (panY.Visible == true)
                    {
                        if (cboYes.Checked == true) { haveanswer = "yes"; }
                        else if (cboNo.Checked == true) { haveanswer = "no"; }
                    }
    }我是要在其他界面 调用到这个方法  
      

  2.   

    先把方法public,把要用到的控件也public
      

  3.   

    ((radiobutton)用户控件.FindControl("单选框id")).selectedvalue; 
      

  4.   

    最简单的就是把外部要用的把一层一层的都给public
      

  5.   

    UC_Options uco = new UC_Options();  这是用户控件 new  
                    uco.RecordQuestions(); 调用方法
    然后得不到我想要的当前值
      

  6.   

    但是你在窗体上拖拽控件生成的控件的引用默认都是private的,在属性窗口的访问修饰符项里面改成public
      

  7.   

    cboYes这个控件不在你的要调用他的方法的页面上,你咋调用,除非你new一个。我猜测你是想用其他页面上的数据更新cboYes所在页面的状态。对吗?