0

I ve an issue with a listview.

Im doing that when delete button is clicked in the listview:(code simplified, it delete as it should)

Protected Sub rlvCarts_ItemCommand(sender As Object, e As RadListViewCommandEventArgs)
        If e.CommandName = RadListView.DeleteCommandName Then
                           mylistItem.items.RemoveAt(e.CommandArgument.ToString)                    
            BindData()            
        End If
End Sub

 Protected Sub BindData()
     rlvCarts.DataSource = mylistItem.items
     rlvCarts.DataBind()
 End Sub

The issue comes when deleteting it will perform itemdatabound twice (but listview prerender once).

How does it come? How can I avoid that?

Aristos
  • 66,005
  • 16
  • 114
  • 150
  • This mix up names is lead to bugs. Use the IsPostBack in the correct point to avoid this twice call. – Aristos Jun 14 '12 at 10:05
  • you might be calling BindData() on pageload also, without apply !ispostback – Raab Jun 14 '12 at 10:06
  • I'm testing postback as it should (beside listview prerender is called once) –  Jun 14 '12 at 10:10

1 Answers1

0

Resolved: I had to add e.Canceled = True

Protected Sub rlvCarts_ItemCommand(sender As Object, e As RadListViewCommandEventArgs)
        If e.CommandName = RadListView.DeleteCommandName Then
                           mylistItem.items.RemoveAt(e.CommandArgument.ToString)   
            e.Canceled = True     
            BindData()            
        End If
End Sub

It prevents the "auto rebind" when a command is called

Community
  • 1
  • 1