Hi I have created linkbuttons dynamically using the below code
Linkbuttons are successfully generated. When i click one of the linkbutton. The command event doesn't fired. While I have Add command event handler to the linkbuttons.
What is wrong in my code
Thanks
Code:
Sub createlinkbutton(ByVal commandtext As String, ByVal Cmdarg As String, ByVal pane As Panel, ByVal count As Int32)
Dim i = 0
Dim panel1 As Panel = New Panel
panel1.CssClass = "boxx"
pane.Controls.Add(panel1)
Dim lbButton As LinkButton = New LinkButton
lbButton.Text = commandtext
lbButton.CommandName = commandtext
lbButton.CommandArgument = Cmdarg
AddHandler lbButton.Command, AddressOf Me.LinkButton_Command
panel1.Controls.Add(lbButton)
End Sub
Protected Sub LinkButton_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
If e.CommandArgument.ToString = "Region" Then
Session("Region") = e.CommandName
End If
If e.CommandArgument.ToString = "LEA" Then
Session("LEA") = e.CommandName
End If
If e.CommandArgument.ToString = "Subject" Then
Session("Subject") = e.CommandName
End If
If e.CommandArgument.ToString = "Position" Then
Session("Position") = e.CommandName
End If
If e.CommandArgument.ToString = "SchoolPhase" Then
Session("SchoolPhase") = e.CommandName
End If
Response.Write("<script language=""javascript"">alert(""" & Session("Region") & """)</script>")
populate()
End Sub
Linkbuttons are successfully generated. When i click one of the linkbutton. The command event doesn't fired. While I have Add command event handler to the linkbuttons.
What is wrong in my code
Thanks
Comment