Click here to Skip to main content
15,894,646 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear All,

Find my code below

VB
Dim hTable As New HtmlTable()


Private Sub makeHTML(ByVal pDataSet As DataSet)

Dim lRowCount As Integer = 0
Dim lColCount As Integer = 0
Dim hCell(23) As HtmlTableCell

Dim lHyperLink(pDataSet.Tables(0).Rows.Count) As LinkButton

While lRowCount < pDataSet.Tables(0).Rows.Count 

Dim hRow As New HtmlTableRow

lHyperLink(lRowCount) = New LinkButton()
lHyperLink(lRowCount).Text = "Hello"
lHyperLink(lRowCount).ID = "LBHLink" + lRowCount.ToString

AddHandler lHyperLink(lRowCount).Click, AddressOf lHyperLink_Click

hCell(lColCount).Controls.Add(lHyperLink(lRowCount))
lRowCount += 1

End While
hTable.Rows.Add(hRow)
    TblPanel.Controls.Add(hTable)

  End Sub



 Protected Sub lHyperLink_Click(ByVal sender As Object, ByVal e As System.EventArgs)

' Handled event actions here

  End Sub


Event handler is not getting called.

Kindly help.
Posted
Updated 17-Jul-15 2:08am
v3

1 solution

Hi,

With little modification it should work now as below.

VB
Private Sub makeHTML(ByVal pDataSet As DataSet)

Dim lRowCount As Integer = 0
Dim lColCount As Integer = 0
Dim hCell As New HtmlTableCell

Dim lHyperLink(pDataSet.Tables(0).Rows.Count) As LinkButton

While lRowCount < pDataSet.Tables(0).Rows.Count

    Dim hRow As New HtmlTableRow
    hRow.Cells.Add(hCell)

    lHyperLink(lRowCount) = New LinkButton()
    lHyperLink(lRowCount).Text = "Hello"
    lHyperLink(lRowCount).ID = "LBHLink" + lRowCount.ToString

    AddHandler lHyperLink(lRowCount).Click, AddressOf lHyperLink_Click

    hRow.Cells(lColCount).Controls.Add(lHyperLink(lRowCount))
    lRowCount += 1

    hTable.Rows.Add(hRow)

End While

tPanel.Controls.Add(hTable)

End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900