Howdy,
Let me post my code first then give a brief description.
I have a linkbutton and a panel on the form.
Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
Dim rowCount As Integer
'For rowCount = 0 To 5
Dim lnkArchiveTitle As New LinkButton
lnkArchiveTitle.Text = "This is the text of the linkbutton " & rowCount
Panel1.Controls.Add(lnkArchiveTitle)
AddHandler lnkArchiveTitle.Click, AddressOf lnkArchiveTitle_Click
'Next
End Sub
Private Sub lnkArchiveTitle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkArchiveTitle.Click
If Me.IsPostBack = True Then
Panel1.Visible = False
End If
End Sub
I also added lnkArchiveTitle as a link button as a protected withevent.
Maybe someone has some options or other alternatives but I am working on a fairly basic journal. What I would like to do is have an Archive section, someone clicks that button, and it dynamically adds LinkButtons depending on how many entries are in the database. (Ultimately grouped by year) For example. 5 Entries for 2005 and it generates the link button, and it sets the text of the link button to the Title of the journal entry from the database. Then when clicked on to display the correct journal entry. So when I add the link button it some how has to have associated with it an identifier.
The primary issue I am having at the moment is getting the click event to work, to show and hide the panel. Really it could be anything, I did have a Response.Write("Write some text") in there as well. This is just a testing page so nothing has been implemented yet.
Any help would be appricated.
Let me post my code first then give a brief description.
I have a linkbutton and a panel on the form.
Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
Dim rowCount As Integer
'For rowCount = 0 To 5
Dim lnkArchiveTitle As New LinkButton
lnkArchiveTitle.Text = "This is the text of the linkbutton " & rowCount
Panel1.Controls.Add(lnkArchiveTitle)
AddHandler lnkArchiveTitle.Click, AddressOf lnkArchiveTitle_Click
'Next
End Sub
Private Sub lnkArchiveTitle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkArchiveTitle.Click
If Me.IsPostBack = True Then
Panel1.Visible = False
End If
End Sub
I also added lnkArchiveTitle as a link button as a protected withevent.
Maybe someone has some options or other alternatives but I am working on a fairly basic journal. What I would like to do is have an Archive section, someone clicks that button, and it dynamically adds LinkButtons depending on how many entries are in the database. (Ultimately grouped by year) For example. 5 Entries for 2005 and it generates the link button, and it sets the text of the link button to the Title of the journal entry from the database. Then when clicked on to display the correct journal entry. So when I add the link button it some how has to have associated with it an identifier.
The primary issue I am having at the moment is getting the click event to work, to show and hide the panel. Really it could be anything, I did have a Response.Write("Write some text") in there as well. This is just a testing page so nothing has been implemented yet.
Any help would be appricated.