Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...