views:

697

answers:

3

Similar questions to this one have been asked but none seem to address my exact situation here's what I am trying to do.

I have a user control that manages student info. i.e. FirstName, LastName, Address etc.

I have a webpage/form that has a button on it. "Add Student". What I want to accomplish is for a new StudentInfo control to be added to the webform after each click.

My current code looks something like this

Private Sub btnAddStudent_Click(sender as object, ByVal e As System.EventArgs)
Dim lStudentInfo as Control

LoadControl("~/StudentInfo.ascx")

Me.placeholder1.controls.add(lStudentInfo)

End Sub

With this code only one StudentInfo control is added and upon pressing the "Add" button again a new StudentInfo control isnt added below the first one and the text/data entered within the first control is cleared.

Thanks in advance for any assistance.

+3  A: 
Joel Coehoorn
A: 

Thanx for thread. It helped. And it figured from: "This means either on Init or PreInit." that at PreInit u dont have Me.placeholder1 yet - so OnInit override is right place.

The
A: 

Thanks a lot!!! This article really helped me.

Abhijeet