Community discussion forum

Gridview -> Template Field -> Button

  • 1 year ago
    Hi, I have two buttons that are within the template field, of a gridview. The gridview is in a web control. I am able to deletage most of the events that the gridview fires, with the code below:- AddHandler ProductGrid.RowEditing, AddressOf gvProduct_RowEditing AddHandler ProductGrid.RowCancelingEdit, AddressOf gvProduct_RowCancelingEdit AddHandler ProductGrid.RowUpdating, AddressOf gvProduct_RowUpdating AddHandler ProductGrid.RowDataBound, AddressOf gvProduct_RowDataBound They work as expected, no issues. However I can not get the event to fire once I click the button. Other websites suggest that the following will work:- AddHandler ProductGrid.RowCommand, AddressOf gvProduct_RowCommand However when I click the button, that event doesn't fire. I am using VB.NET 2005. Any help would be most appreciated!
  • 1 year ago
    When you click a button in gridview it will fire a rowcommand event (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowcommand.aspx). Maybe you have something wrong when you add the event handler. Try adding it via the designer to see if it works then. I've also had some problems in datagrid which probably acts the same way than gridview with some buttons hitting the oncommand event. If I remember correctly the problem was with buttons but not with linkbuttons. You can workaround the problem by checking where you bind the grid. I can't rememer how it was but if you bind it with every page load, try binding it only when not postback or the other way around.

Post a reply

Enter your message below

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

We'd love to hear what you think! Submit ideas or give us feedback