锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
聽
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