Link to home
Start Free TrialLog in
Avatar of Member_2_5230414
Member_2_5230414

asked on

how to set button click if id is set dynamicly

Hello,

I have set a list of link buttons dynamically (shown below)

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim dtholidays As New DataTable()
        dtholidays = dateallreadybooked.getusers()
        Dim myhols As DataView
        myhols = New DataView(dtholidays, "", "", DataViewRowState.CurrentRows)

        For Each Dayitis In myhols

            Dim linkbutton As New LinkButton
            linkbutton.Text = Dayitis.Item("FirstName") & " " & Dayitis.Item("Surename")
            linkbutton.ID = Dayitis.Item("Surename")
            Dim newline As String = Environment.NewLine
            holder.Controls.Add(linkbutton)
            Dim spacer As New System.Web.UI.WebControls.Label
            spacer.Text = "<br />"
            holder.Controls.Add(spacer)
        Next
    End Sub

Open in new window


how could i set the onlcick method so its basiclylike the below


  Protected Sub Dayitis.Item("FirstName")_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Dayitis.Item("FirstName").Click

    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rajar Ahmed
Rajar Ahmed
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial