Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim lbl_Date As New Label
Dim i as int16
i = 20
While (i < i + 1)
lbl_Date = TryCast(Page.FindControl("lbl_Date" + i.ToString), Label)
lbl_Date = "Value"
i = i + 1
End While
End Sub
This is returning Nothing in lbl_Date variable. If i don’t use this in Page_Load, it works just fine. Only in Page_Load it doesn’t work. Any Explanation :::: Well what i am trying to do here is . i have 100 label name are lable1 to lable100. I can do like label1 =Value and label2 =Value and so on but i am trying to put in loop so i have less code. just for the Info… This code work but not in Page_Load , I am thinking every one looking to the code but this has to do with page life cycle
Problem was , I didn’t Used DIV in my aspx page . When i put my code in div and use the reference of the div in codebehind then it work.