asp.Net does not exist in current context

后端 未结 10 1952
夕颜
夕颜 2021-02-07 08:39

I am facing a small big problem. I have taken a dropdownList control and ID is \"drpDownCountries\" in ASP.Net project. The problem is that \"The dropdownlist contr

10条回答
  •  半阙折子戏
    2021-02-07 09:46

    You should put some code to get help..

    Anyway, the problem could be that drpDownCountries is contained within a Panel control.

    The Panel control is a Container control, in that it can hold lots of controls.
    In order to access the controls within that Panel control, you first need to "help" ASP.Net to find it.

    The typical way of doing this is to use the FindControl method look here.

    Code sample:

    DropDownList myDrop = (DropDownList)this.Panel1.FindControl("drpDownCountries");
     if(myDrop != null)
      {
         ..somecode..
      }
    

提交回复
热议问题