943,693 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 4645
  • ASP.NET RSS
Jun 26th, 2009
0

Handler attached to Button.Click inside Gridview not firing

Expand Post »
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
ASP.NET Syntax (Toggle Plain Text)
  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
ASP.NET Syntax (Toggle Plain Text)
  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.  
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
culebrin is offline Offline
62 posts
since Aug 2007
Jun 26th, 2009
0

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

Try:

ASP.NET Syntax (Toggle Plain Text)
  1. buttonName.PostBackUrl="javascript:void(0);"
Reputation Points: 22
Solved Threads: 13
Junior Poster in Training
IdanS is offline Offline
96 posts
since Jun 2009
Jul 6th, 2009
0

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

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...
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
culebrin is offline Offline
62 posts
since Aug 2007
Jul 8th, 2009
0

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

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.
Reputation Points: 26
Solved Threads: 44
Posting Whiz in Training
mail2saion is offline Offline
247 posts
since Apr 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: dynamic comments box
Next Thread in ASP.NET Forum Timeline: disabling datagrid hyperlink column underline





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC