Used RowCommand - now my standard 'edit' doesn't work!


B

Bobby Edward

I am using a databound gridview control. I have a standard 'edit' button
(with save/cancel.) I wrote no code for this. It worked great!

Then I added a template field for a 'delete' linkbutton which does some
CUSTOM events in addition to deleting.

I use the RowCommand event of the gridview in order to run the custom
'delete' code. But now my 'edit' button (no code) doesn't work. Any reason
why?

Here's the code...

Protected Sub gvSubusers_RowCommand(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewCommandEventArgs) Handles
gvSubusers.RowCommand
If e.CommandName = "DeleteSubUser" Then
' CUSTOM DELETE CODE
Dim u As New MyCompany.BusinessLogicLayer.Users.Users
Try
Dim lb As LinkButton = CType(e.CommandSource, LinkButton)
Dim row As GridViewRow = CType(lb.NamingContainer,
GridViewRow)
Dim id As Integer =
CInt(gvSubusers.DataKeys(row.RowIndex).Values(0))

u.DeleteSubuser(id) ' run some custom cleanup in addition
Page.DataBind()
Catch ex As Exception
lblStatus.Text = ex.ToString
lblStatus.ForeColor = Drawing.Color.Red
End Try
End If
End Sub
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top