Thanks for the feedback. I just tried it, and it didn't work for me. That may set everything up correctly and try to run the code, but I guess there's another problem with the nested gridviews. When I try to run server-side code that's initiated by a nested gridview, the postback causes the gridview to vanish (because it’s dynamic and not being rebuilt) and it still doesn't run the code that’s in the RowEditing or RowDeleting events.
For anybody that’s stuck on a similar problem, I do have a work-around until I can figure out how to fix it. I created a hidden textbox and a hidden button. I put the server-side code that I want to run in the hidden_button_click event and I use the hidden_textbox to store values from the gridview for editing and deleting purposes. On the RowDatabound event of the nested gridview, I added javascript to the "onClick" event of the delete_button and the edit_button that will fill the hidden_textbox and "click" the hidden_button to run the events. The key is to finish the "onCick" events with "return false;" so the gridview is not initiating the postback.
Here’s the code:
- Dim ImageButton_Edit As ImageButton = CType(e.Row.Cells(2).Controls(0), ImageButton)
-
-
Dim ImageButton_Delete As ImageButton = CType(e.Row.Cells(3).Controls(0), ImageButton)
-
-
ImageButton_Edit.Attributes.Add("onClick", "document.getElementById('" & TextBox_SC_Edit_Delete.ClientID & "').value = " & e.Row.Cells(4).Text.ToString() & "; document.getElementById('" & Button_SC_Edit.ClientID & "').click(); return false;")
-
-
ImageButton_Delete.Attributes.Add("onClick", "if (confirm('Are you sure you want to delete this Scorecard?')==false) return false; document.getElementById('" & TextBox_SC_Edit_Delete.ClientID & "').value = " & e.Row.Cells(4).Text.ToString() & "; document.getElementById('" & Button_SC_Delete.ClientID & "').click(); return false;")
-
-
Private Sub Button_SC_Edit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button_SC_Edit.Click
-
Response.Redirect("SCWizard.aspx?Edit_SC_Key=" & TextBox_SC_Edit_Delete.Text)
-
End Sub
-
-
Private Sub Button_SC_Delete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button_SC_Delete.Click
-
Response.Redirect("Default.aspx?Delete_SC_Key=" & TextBox_SC_Edit_Delete.Text)
-
End Sub
-