Hi All, I am having a little trouble using a repeater control. I have the control on my page and it populates with the data I want fine.
However when I try to click the Delete linklabel I place in the last column of the repeater, the ItemCommand event doesnt even fire, and I am at a loss to why.
Here are both my ItemDataBound and ItemCommand subs.
Protected Sub DataDisplay_ItemDataBound(ByVal sender As Object, ByVal X As RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
If (X.Item.ItemType = ListItemType.Item) Or (X.Item.ItemType = ListItemType.AlternatingItem) Then
Dim lblDate As Label = CType(X.Item.FindControl("lblDate"), Label)
lblDate.Text = DataBinder.Eval(X.Item.DataItem, "Date")
Dim lblFrom As Label = CType(X.Item.FindControl("lblFrom"), Label)
lblFrom.Text = DataBinder.Eval(X.Item.DataItem, "From")
Dim lblSubject As Label = CType(X.Item.FindControl("lblSubject"), Label)
lblSubject.Text = DataBinder.Eval(X.Item.DataItem, "Subject")
Dim txtMessID As TextBox = CType(X.Item.FindControl("txtMsgID"), TextBox)
txtMessID.Text = DataBinder.Eval(X.Item.DataItem, "MsgID")
txtMessID.Visible = True
Dim lnkDelete As LinkButton = CType(X.Item.FindControl("lnkDelete"), LinkButton)
lnkDelete.Text = "Delete"
lnkDelete.CausesValidation = "False"
lnkDelete.CommandName = "Delete"
End If
End Sub
Protected Sub DataDisplay_ItemCommand(ByVal source As Object, ByVal X As RepeaterCommandEventArgs) Handles Repeater1.ItemCommand
If X.CommandName.CompareTo("Delete") = 0 Then
Dim txtMsgID As TextBox = CType(X.Item.FindControl("txtMsgID"), TextBox)
Dim MsgID As Integer
MsgID = Int32.Parse(txtMsgID.Text)
' Delete the current message, passing the connection string and the current messageID
BindingControl.myGenDal.MessageDelete(_ConnString, Int32.Parse(txtMsgID.Text))
Dim myMessList As New List(Of GeneralSite.Message)
myMessList = BindingControl.myGenDal.ListAllMessages(_ConnString, BindingControl.myAccessInfo.EmployeeNo)
BuildData(myMessList)
' Redirect
Response.Redirect("Messages.aspx")
End If
End Sub
If anyone has any idea why the DataDisplay_ItemCommand never fires, I would love to know.
Kind Regards
Enter your message below
Sign in or Join us (it's free).