User-629624826 posted
Good day, I have a detail with my GridView, which filled it with all the information I want, the detail I have is that at run time I add rows to my grid, sometimes it is not necessary but in others if, when insert rows I have buttons in my main row
and when I click them, the event they have defined does not enter. When rows are not added dynamically all the buttons work correctly. To keep the dynamic information if it is generated, what I realize is that in the action of the buttons, re-fill my grid
to load it again. But they can guide me about the problem that I have, I leave some code that I use to generate my rows and an example of what I want to do.
This is a example grid:

Use BoundField and TemplateField for fixed columns.
Every time I generate a dynamic row I do it in the following way in the RowDataBound:
Dim gvr1 As New GridViewRow(0, -1, DataControlRowType.DataRow, DataControlRowState.Normal)
Dim thc5 As New TableCell
thc5.ColumnSpan = 2
thc5.Text = "Comments:"
gvr1.Cells.Add(thc5)
Dim thc6 As New TableCell
thc6.ColumnSpan = 24
thc6.Style("font-weight") = "bold"
thc6.Text = "textBox Commentarios"
gvr1.Cells.Add(thc6)
grdPrueba.Controls(0).Controls.Add(gvr1)
The grid loads well the first time, and my buttons declare them as follows:
<asp:TemplateField ItemStyle-CssClass="saveBtn">
<ItemTemplate>
<asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSve" />
</ItemTemplate>
</asp:TemplateField>
The event in the code is as follows:
Protected Sub btnSve(ByVal sender As Object, ByVal e As System.EventArgs)
response.write("Test")
llenarGrid()
End Sub
Can you guide me on how I can solve this part? or what do you recommend, thank you.