ASP.NET, VB: how to access controls inside a FormView from the code behind?

前端 未结 3 1851
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-30 12:06

I have a checkbox and a panel inside of a FormView control, and I need to access them from the code behind in order to use the checkbox to determine whether or not the panel

3条回答
  •  囚心锁ツ
    2020-12-30 12:36

    With FormView, you have to use find control, as in:

    CheckBox checkGenEd = (CheckBox)formview1.FindControl("checkGenEd");
    Panel panelOutcome = (Panel)formview1.FindControl("panelOutcome");
    

    You cannot reference a control directly by ID.

    HTH.

提交回复
热议问题