Hi,
I need to add labels to a form dynamically. The number of labels to be added is driven by a variable stored in session. The labels should have text like "Label 1", Label 2", "Label 3" and so forth. I am trying to create these controls in the page_load event. But it throws an unhandled exception.
Help?
Jino
I need to add labels to a form dynamically. The number of labels to be added is driven by a variable stored in session. The labels should have text like "Label 1", Label 2", "Label 3" and so forth. I am trying to create these controls in the page_load event. But it throws an unhandled exception.
Code:
dim i as integer
If numberInSession > 0 then
For i=1 to numberInSession
dim myLabel as System.Web.UI.WebControls.Label
Me.FindControl("Form1").Controls.Add(myLabel)
myLabel.Text = "Label" & i
Next
End If
Help?
Jino