
Originally Posted by
Lightning
If you rebind the data in the pre-init event, you can foreach thru the items in the repeater. Using item.FindControl("chkLikeComment") you can get all the "likecommennt checkboxes" and add the eventhandlers
Ok, so i tried to set up the pre-init as follows:
Code:
Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
rptComments.DataSource = GetPostComments()
rptComments.DataBind()
For Each CommentItem As RepeaterItem In rptComments.Items
Dim CheckLike As CheckBox = CType(CommentItem.FindControl("chkLikeComment"), CheckBox)
CheckLike.AutoPostBack = True
CheckLike.CheckedChanged += New EventHandler(chkLikeComment_CheckedChanged)
Next
End Sub
However, the statement
Code:
CheckLike.CheckedChanged += New EventHandler(chkLikeComment_CheckedChanged)
get blue underlined with an error in 2 places
CheckLike.CheckedChanged gets the error stating that it is an event and cannot be called directly and to use raise event instead..
chkLikeComment_CheckedChanged gets the error stating that "Delegate 'System.EventHandler' requires an 'AddressOf' expression or lambda expression as the only argument to it's constructor"
Am i adding the event handlers wrong? Or have i set up the preinit wrong in some way?