你有用 FindControl 時找不到 Control (控制項) 的經驗嗎

你有用 FindControl 時找不到 Control (控制項) 的經驗嗎

https://blog.miniasp.com/post/2007/11/04/ASPNET-FindControl-Tips-and-Hacks.aspx

 

    Protected Sub ImageButton1_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs)
        Dim Calendar11 As New Calendar
        Calendar11 = GridView1.Rows(GridView1.EditIndex).Cells(3).FindControl("Calendar1")
        Calendar11.Visible = True
    End Sub


    
    Protected Sub Calendar1_SelectionChanged(sender As Object, e As System.EventArgs)
        Dim Calendar12 As New Calendar 
        Dim TextBox22 As New TextBox
        Calendar12 = GridView1.Rows(GridView1.EditIndex).Cells(3).FindControl("Calendar1")
        TextBox22 = GridView1.Rows(GridView1.EditIndex).Cells(3).FindControl("TextBox2")

        TextBox22.Text = Calendar12.SelectedDate.ToShortDateString()

        Calendar12.Visible = False
    End Sub

    '再GridView內的元件,使用以上取得GridView的Calendar後 ,用來接收,再進行控制