How do i go about putting textboxes and dropdown lists onto a page repeatedly?? ie
While counter <= myIntValue
'Draw a label
'Draw a textbox
'Draw a button
End While
I have googled it for a week now but cant find what i need. thanks for any help!!
in the aspx file, add between the <form> tags:
<asp:PlaceHolder id="PlaceHolder1" runat="server"></asp:PlaceHolder>
That adds this to the CodeBehind file:
Protected PlaceHolder1 As System.Web.UI.WebControls.PlaceHolder
' In the Page_Load handler:
Dim i As Integer
For i = 0 To myIntValue - 1
' On all except the first group, add a new line...
If i > 0 Then
Me.PlaceHolder1.Controls.Add(New LiteralControl("<br>"))
End If
' Add a Label...
Dim newLabel As New Label()
newLabel.ID = "Label" + i
newLabel.Text = "some-text"
Me.PlaceHolder1.Controls.Add(newLabel)
' Add a TextBox...
Dim newTextBox As New TextBox()
newTextBox.ID = "TextBox" + i
newTextBox.Text = "some-text"
Me.PlaceHolder1.Controls.Add(newTextBox)
' Add a Button...
Dim newButton As New Button()
newButton.ID = "Button" + i
newButton.Text = "some-text"
Me.PlaceHolder1.Controls.Add(newButton)
' Add an event for the Button...
AddHandler newButton.Click, AddressOf newButton_Click
Next i
' The Button's event handler:
Private Sub newButton_Click(sender As Object, e As System.EventArgs)
' For this demo, we just write the Button ID to the screen...
Me.Response.Write(("newButton_Click fired from: " + CType(sender, Button).ID + "<br>"))
End Sub
NC...
Thank you NC01 for the help! its much appreciated!!
0 comments:
Post a Comment