Gridview -> Template Field -> Button , asp , .net Tulsa, United States
  • 12 years 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!
  • 12 years ago
    When you click a button in gridview it will fire a rowcommand event ( 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).


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.

“Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” - Rick Osborne