Handler attached to Button.Click inside Gridview not firing

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2007
Posts: 55
Reputation: culebrin is an unknown quantity at this point 
Solved Threads: 1
culebrin culebrin is offline Offline
Junior Poster in Training

Handler attached to Button.Click inside Gridview not firing

 
0
  #1
Jun 26th, 2009
Hi,

I have a Button inside of a GridView, inside of another GridView.

The higher gv is filled with a dataset, and in the RowCreated event I fill the second gv, and finally, in the RowCreated event (handler added in the RowCreated event of the first gv) of the second gv, attach the handler of the Click event with the button inside.

I have another controls in the same way with their own events added and works fine, but this Button dont... When I press the button, it postback but the event is like not been called (even when I debugged and the rowcreated reach the line with the addhandler for the button)

Maybe some one can guide me through this...

aspx
  1. <asp:Content ID="cVentanillaAtencionFlujo" ContentPlaceHolderID="cphVentanillaAtencionMaster" Runat="Server">
  2. <asp:ScriptManager ID="smVentanillaAtencionFlujo" runat="server">
  3. </asp:ScriptManager>
  4.  
  5. <asp:GridView BackColor="LightGray" ShowHeader="False" ID="gvFasesListar" runat="server" AutoGenerateColumns="False"
  6. Width="728px" DataKeyNames="inFasCodigo">
  7. <Columns>
  8. <asp:TemplateField>
  9. <ItemTemplate>
  10. <table cellpadding="0" cellspacing="0" style="width: 672px; background-color:#FFFFFF">
  11. <tr>
  12. <td align="right">
  13. <asp:Button ID="btnActualizarResultadosTest" CausesValidation="false" runat="server" Text="Actualizar" Width="120px" />
  14. </td>
  15. </tr>
  16. </table>
  17. </ItemTemplate>
  18. </asp:TemplateField>
  19. </Columns>
  20. </asp:GridView>
  21.  
  22. </asp:Content>

Code behind
  1. If e.Row.RowType = DataControlRowType.DataRow Then
  2. Dim btnActualizarResultadosTest As New WebControls.Button
  3. btnActualizarResultadosTest = e.Row.FindControl("btnActualizarResultadosTest")
  4. If Not btnActualizarResultadosTest Is Nothing Then
  5. 'AddHandler btnActualizarResultadosTest.Click, AddressOf btnActualizarResultadosTest_Click
  6. AddHandler btnActualizarResultadosTest.Command, AddressOf btnActualizarResultadosTest_Command
  7. End If
  8. End If
  9.  
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 88
Reputation: IdanS is an unknown quantity at this point 
Solved Threads: 12
IdanS IdanS is offline Offline
Junior Poster in Training

Re: Handler attached to Button.Click inside Gridview not firing

 
0
  #2
Jun 26th, 2009
Try:

  1. buttonName.PostBackUrl="javascript:void(0);"
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 55
Reputation: culebrin is an unknown quantity at this point 
Solved Threads: 1
culebrin culebrin is offline Offline
Junior Poster in Training

Re: Handler attached to Button.Click inside Gridview not firing

 
0
  #3
Jul 6th, 2009
Thanks... but I tried it, and It didn't worked. I just have to give up that idea, coz I'm on a schedule...

Thank you very much...
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 217
Reputation: mail2saion is an unknown quantity at this point 
Solved Threads: 31
mail2saion's Avatar
mail2saion mail2saion is offline Offline
Posting Whiz in Training

Re: Handler attached to Button.Click inside Gridview not firing

 
0
  #4
Jul 8th, 2009
Just go to design view. Open the template column then add the event in design view. Set commandname when bind data. Now in the click event catch the command value & do the next job.

The way you used is basically needed when you create dynamic control otherwise try to avoid unnecessary complexity.
Last edited by mail2saion; Jul 8th, 2009 at 12:57 am.
MARK AS SOLVED if its help you.

REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC