Part 1 :Qusetion Details:(that's not really i wrote,i just quote a same sample as my encountered)
have a gridview and the GridView_RowEditing event is firing twice when I click the edit button and the GridView_RowDeleting event is firing twice on a single delete. I don't think there's anything that I'm doing in my code that would cause this, but I'm including the code for the two events. Has anyone encountered this problem?
Here's the code for RowEditing:
<code>
Protected Sub gv_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles gv.RowEditing
gv.Columns(columnIndex.Delete).Visible = True
gv.Columns(columnIndex.Id).Visible = False
gv.EditIndex = e.NewEditIndex
End Sub
</code>
And here's the code for RowDeleting:
<code>
Protected Sub gv_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles gv.RowDeleting
e.Cancel = True
Dim lblFName As Label
lblFName= CType(gv.Rows(gv.EditIndex).FindControl("lblFName"), Label)
Dim lblLName As Label
lblLName= CType(gv.Rows(gv.EditIndex).FindControl("lblLName"), Label)
myObject.myClass.DeleteTemp(CType(lblBookletNum.Text, Integer), lblCare.Text)
gvTempVisits.EditIndex = -1
End Sub
</code>
Part 2 : A Reply From Someone
verify if in the declarative code of your GridView control are set the OnRowDeleting and OnRowEditing attributes. If so, remove either this attributes or the Handles clauses of your handler events.
I mean if your gridview is declared as follows:
[...]
<asp:GridView id="gv" runat="Server" OnRowDeleting="gv_RowDeleting" OnRowEditing="gv_RowEditing"
>
[...]
</asp:GridView>
[...]
And in your methods to handle the events are as follows:
[...]
Protected Sub gv_RowDeleting(............)
Handles gv.RowDeleting
[...]
End Sub
[...]
This events will be called twice.
Part 3: A Great Discussion about it i found !
http://www.issociate.de/board/post/285047/help_please_on_GridView_commands_+_AutoEventWireUp