ItemCommand event doesn't fire 1st time in DataGrid

Posted by Sheonarayan under ASP.NET on 7/13/2015 | Points: 10 | Views : 456 | Status : [Administrator] | Replies : 0

I was facing a strange problem while working with DataGrid (older control in I had a asp:ButtonColumn in the DataGrid with command name as "Modify". In OnItemCommand event I was writing some code that was executing only when I was clicking the Modify button two times. In 1st click even the OnItemCommand event was not firing.


To my surprise the solution was pretty simple. For some reason, the asp:ButtonColumn doesn't work in this way so instead of asp:ButtonColumn I added asp:TemplateColumn and under ItemTemplate I kept asp:LinkButton with command name as "Modify". Now it works. Clicking on the Modify button (link) in first attempt it self the OnItemCommand event fires.

Hope this will help someone.


Sheo Narayan


(No response found.)

Login to post response