Why wouldnt this event Fire?

  • 10 years ago

    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
  • 10 years ago
    Hi there,
    I wondered, it works for me. Did you put BreakPoint to see if your DataBound event works properly or not. Confused [*-)]


  • 10 years ago

    Hmmm thats strange, yeah I added break points but it simply isnt called.
    Any chance you could post you code, or even better email me a zipped version, so I could look it over. (mwalker at codegurus dot org)

    Kind Regards

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“In order to understand recursion, one must first understand recursion.”