问题如题后台代码:public static string JudgeIsClearOrNot2(string result, int reportid)
    {
         ddlParent//访问错误
    }前台代码:<asp:DropDownList ID="ddlParent" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlParent_SelectedIndexChanged">
                    </asp:DropDownList>

解决方案 »

  1.   

    可以。
    方法一:通过参数传过来。
    方法二:用FindControl找到这个控件,得写一句很长的代码。
      

  2.   

    string name=(this.GV.Rows[e.RowIndex].FindControl("TextBox1") as TextBox).Text;
    这个例子是我从GridView的文本框中读取的数据。希望对楼主有帮助。
      

  3.   

    可以是可以,但你需要把对像的引用传到方法里.方法可以改造一下
    public static string JudgeIsClearOrNot2<T>(T control,string result, int reportid)
    where T:ListControl
    {
           //statement
    }
      

  4.   

    public static string JudgeIsClearOrNot2(string result, int reportid,DropDownList ddlParent)
        {
             ddlParent//可以访问
        }
      

  5.   

    public static string JudgeIsClearOrNot2(string result, int reportid,DropDownList ddlParent)
    {}
      

  6.   

    我上面的方法可以适用于任何的继承自ListControl的控件,如DropDownList,RadioButtonList,CheckBoxList etc.
      

  7.   


    看了各位朋友的回复,我知道了,通过参数传递是可以调用的。呵呵,如果是要在这个静态的方法里访问20多个前台页面的控件的话,那你还传参数啊,集合到数组里吗?我是JS里调用这个静态方法的啊。呵呵,不过我已经做好了,我的方法是用Session来保存对象。然后就访问Session就可以了。好了,结贴给分