I'm trying to dynamically add 5 buttons to my custom module but I get an error saying that they have the same ID, but they don't, I notice that the page_load is called a lot of times, why is it called so many times?
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Try
Dim objModules As ModuleController = New ModuleController
If Not Page.IsPostBack Then
If (Not (CType(Settings("showform"), String)) Is Nothing) Then
If (CType(Settings("showform"), String) = "No") Then
' Do not allow messages to be added
FormView1.Visible = False
lblAddMessage.Visible = False
End If
End If
Dim n As Integer = 0
For n = 0 To 5
Dim b As Button = New Button()
b.ID = "MyBtn" & n
b.Text = n.ToString
BtnPlaceHolder.Controls.Add(b)
Next
Else
Me.GridView1.DataBind()
End If
Catch ex As Exception
Exceptions.ProcessModuleLoadException(Me, ex)
End Try
End Sub