Adding click event to linkbutton
am 28.12.2007 12:16:18 von FabriHi,
I am new to .NET and need help with adding click event on LinkButton
programatically.
Please see the code below. I would like to add a click event on LinkButton
returned from "Function EditLink". This LinkButton should fire "Sub EditNav"
when clicked.
======================================
Function GetNavTable(ByVal NavType As Integer) As Table
Dim NavTable As New Table
NavTable.CellSpacing = 1
NavTable.CssClass = "contenttable"
NavTable.Width = Unit.Percentage(100)
Dim DataTable As AppDataSet.NavigationDataTable =
BLL.GetNavigationByType(NavType)
Dim RSRow As AppDataSet.NavigationRow
For Each RSRow In DataTable
Dim Row As New TableRow
Dim Header As New TableCell
Dim LinkText As New TableCell
Dim LinkUrl As New TableCell
Dim Sorting As New TableCell
Dim EditCell As New TableCell
Dim EditLink As New LinkButton
EditLink = GetEditLink(RSRow.NavId)
Header.Text = RSRow.NavId
LinkText.Text = RSRow.LinkText
LinkUrl.Text = RSRow.LinkUrl
Sorting.Text = RSRow.Sorting
EditCell.Controls.AddAt(0, EditLink)
Row.Cells.Add(Header)
Row.Cells.Add(LinkText)
Row.Cells.Add(LinkUrl)
Row.Cells.Add(Sorting)
Row.Cells.Add(EditCell)
NavTable.Rows.Add(Row)
Next
Return NavTable
End Function
Function GetEditLink(ByVal NavID As Integer) As LinkButton
Dim EditLink As New LinkButton
'How to make this LinkButton fire the "Sub EditNav" and pass
parameter NavID?
Return EditLink
End Function
Sub EditNav(ByVal NavIID As Integer)
'Code to execute when EditLink is clicked on.
End Sub
=======================================
Any help will be appriciated.
Tnx.