Unable to find control in calendar

Kevin Le posted at 09-May-08 12:36

Hi, I am trying to find the control for a dynamic text box which is created in side a calendar but it 's always give me error. Please help. My dead line for this project is comming. Thanks

Here is my code:

 

Public Class WebForm1

Inherits System.Web.UI.Page

Protected WithEvents Calendar1 As System.Web.UI.WebControls.Calendar

Public dynamicTb As TextBox

Protected WithEvents Button1 As System.Web.UI.WebControls.Button

Protected WithEvents Label1 As System.Web.UI.WebControls.Label

Dim i As Integer

Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

   i = 0

End Sub

Public Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender

   i = i + 1
   dynamicTb =
New TextBox()
   dynamicTb.ID = i
   dynamicTb.Text = "hello " & i
   e.Cell.Controls.Add(dynamicTb)

End Sub

Public Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged

   Dim tb1 As TextBox
   tb1 =
CType(Me.FindControl(1), TextBox) //this line give me error????   Please help

End Sub

End Class

 


Click here to sign in and reply. You could earn money via our $500 contest just for being helpful.
  Unable to find control in calendar - Kevin Le  09-May-08 12:36 12:36:59 PM
      There should be no need to use CType here. - Peter Bromberg  09-May-08 01:30 1:30:16 PM
          Still not work?? Any other suggestions? - Kevin Le  12-May-08 11:22 11:22:43 AM
      Hello use this; - Sujit Patil  09-May-08 11:59 11:59:28 PM
      try this - Chirag Bhavsar  10-May-08 12:26 12:26:58 AM
      need to create dynamic controls in every postback... - Vasanthakumar D  10-May-08 12:30 12:30:59 AM
      Can you try this - Aravind Kumar  11-May-08 06:16 6:16:10 AM
View Posts