rbb Posted April 28, 2005 Posted April 28, 2005 I have a table control that I am dynamicaly adding rows to - which I am building off a session variable that is a datatable. At the end of each row I am adding an imagebutton that will delete the row from both the table and the session datatable. I have it working the first time a user clicks on any of the imagebuttons, but on a second imagebutton click my event is not fired, but I do get a postback. If I click a third time it works as expected, and a fourth click will not raise the event again. In my page_load event I am simply building the table (not checking for postback). In my img_click event I am finding the corresponding row in my session datatable, deleting it, and reloading my table. Here is where I am adding my imagebutton cell = New TableCell Dim img As ImageButton = New ImageButton img.ImageUrl = "img/remove.gif" img.CommandName = "onClick" img.CommandArgument = dr.Item("myID") img.ToolTip = "Remove from cart" AddHandler img.Click, AddressOf img_Click cell.Controls.Add(img) cell.Width = New Unit(25) cell.HorizontalAlign = HorizontalAlign.Right row.Cells.Add(cell) Me.tblMain.Rows.Add(row) So why is my img_click event only fireing every other time? Thanks, Rob Quote
Moderators Robby Posted April 29, 2005 Moderators Posted April 29, 2005 You need to reload the table in the img_click event as you do in your Page_load event, but you also need to limit the page_load routine to "Not IsPostBack" only. Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.