I'm trying to create a dual function CommandButton in an ASP.NET GridView. The reason for this is that the records will come in with an either/or scenario--if they have no dependencies, the record can only be deleted, but if dependencies exist, it can only be updated.
On the GridView I have a CommandButton, and on RowDataBound I set its text to either "Edit" or "Delete". Then in the RowCommand, I have the following (below) code.
The delete part works, great; however, the edit portion puts the row in edit mode, but does not show the update/cancel links
. Any idea how to accomplish this programmatically? Thank you.
Dim Row As GridViewRow = gv.Rows(e.CommandArgument)
Dim btnAction As New LinkButton
btnAction = CType(Row.Cells(2).Controls(0), LinkButton)
Select Case btnAction.Text
gv.EditIndex = Row.RowIndex
Dim lblID As Label = CType(Row.FindControl("lblID"), Label)
Dim iError As Integer = DeleteItem(cint(lblID).text)