How to fix it?
I declared handlers in Page_Load, Page_PreRender and markup. It doesn’t work normaly.
Code:
<asp:GridView ID="tableResults" runat="server" DataMember="Table" EnableModelValidation="True"
CssClass="GridViewStyle" OnRowDeleting="dataViewRowDeleting" AutoGenerateDeleteButton="True">
<HeaderStyle CssClass="GridViewHeaderStyle" />
<RowStyle CssClass="GridViewRowStyle" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" Text="Скачать объект" NavigateUrl='<%#"objects/" + Eval("Идентификатор") %>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Handlers:
tableResults.AutoGenerateEditButton = true;
tableResults.RowEditing += new GridViewEditEventHandler(tableResults_RowEditing);
tableResults.RowUpdating += new GridViewUpdateEventHandler(tableResults_RowUpdating);
tableResults.RowCancelingEdit += new GridViewCancelEditEventHandler(tableResults_RowCancelingEdit);
Alright I tried your code and got the same issue as you. The reason is because you are manually calling Databind in Page_Load but you are not reattaching the datasource. You need reattach your datasource in your edit event handler (as well as other event handlers).
If you don’t want to do it manually you need to use the data source control.