| | |
Handler attached to Button.Click inside Gridview not firing
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2007
Posts: 55
Reputation:
Solved Threads: 1
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
Code behind
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)
<asp:Content ID="cVentanillaAtencionFlujo" ContentPlaceHolderID="cphVentanillaAtencionMaster" Runat="Server"> <asp:ScriptManager ID="smVentanillaAtencionFlujo" runat="server"> </asp:ScriptManager> <asp:GridView BackColor="LightGray" ShowHeader="False" ID="gvFasesListar" runat="server" AutoGenerateColumns="False" Width="728px" DataKeyNames="inFasCodigo"> <Columns> <asp:TemplateField> <ItemTemplate> <table cellpadding="0" cellspacing="0" style="width: 672px; background-color:#FFFFFF"> <tr> <td align="right"> <asp:Button ID="btnActualizarResultadosTest" CausesValidation="false" runat="server" Text="Actualizar" Width="120px" /> </td> </tr> </table> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </asp:Content>
Code behind
ASP.NET Syntax (Toggle Plain Text)
If e.Row.RowType = DataControlRowType.DataRow Then Dim btnActualizarResultadosTest As New WebControls.Button btnActualizarResultadosTest = e.Row.FindControl("btnActualizarResultadosTest") If Not btnActualizarResultadosTest Is Nothing Then 'AddHandler btnActualizarResultadosTest.Click, AddressOf btnActualizarResultadosTest_Click AddHandler btnActualizarResultadosTest.Command, AddressOf btnActualizarResultadosTest_Command End If End If
•
•
Join Date: Jun 2009
Posts: 88
Reputation:
Solved Threads: 12
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.
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
REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
![]() |
Similar Threads
- raise event handler for image button (ASP.NET)
- adding button click event in javascript (JavaScript / DHTML / AJAX)
- Select entire row details on click of button of that row inside a GridView (ASP.NET)
- Passing value of string from one button click event to another (ASP.NET)
- Calling button-click events from different classes (Python)
- Enter doesn't execute button.click (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: dynamic comments box
- Next Thread: disabling datagrid hyperlink column underline
| Thread Tools | Search this Thread |
.net 2.0 3.5 ajax alltypeofvideos appliances asp asp.net beginner box browser businesslogiclayer button c# c#gridviewcolumn cac checkbox class compatible confirmationcodegeneration content contenttype countryselector courier dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv forms gridview gudi homeedition iis javascript jquery list listbox menu microsoft mouse mssql nameisnotdeclared news novell numerical opera order panelmasterpagebuttoncontrols problem radio ratings redirect registration relationaldatabases reportemail schoolproject search security serializesmo.table sessionvariables silverlight smoobjects software sql sql-server ssl tracking treeview validatedate validation vb.net videos vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment webprogramming webservice xml xsl





