Grosso bug della nuova versione.
In un gridview con imagebutton il postback viene eseguito due volte (non sempre!)

Riferimento:
http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/browse_frm/thread/d32e4efa2d10e573

Mentre Microsoft risolve il problema, state attenti a inserire bottoni per spostare le righe della griglia, potrebbe spostarle di due posizioni!
Il problema è che il postback viene eseguito due volte (si nota in debug). A volte viene eseguita una richiesta aggiuntiva priva delle coordinate del mouse sul bottone (al click)
Altri che hanno rivelato il problema?
Ciao,

Ormai programmano tutti... ma la professionalità appartiene a pochi
La soluzione dell'autoeventwireup non è quella esatta come puoi leggere dal mio link e dalla continuazione di quello che hai segnalato tu...
Grazie cmq!

Ho trovato la risposta altrove, firmata Microsoft:

Thanks for reporting the issue. This is a known issue and we are investigating fixing this in the next service pack. For the time being you could use the following work around. One obvious workaround is to change the button type to a regular button or a link button. If you need an ImageButton, then you can put an ImageButton in a TemplateField. You may need to handle the Command event on the ImageButton and call DeleteRow, passing the RowIndex as the CommandArgument, like this:

<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton runat=server id="ImageButton1" CommandName="Delete" ImageUrl="..." CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>' OnCommand="ImageButton1_Command" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

protected void ImageButton1_Command(object sender, CommandEventArgs e) {
GridView1.DeleteRow(Int32.Parse(e.CommandArgument.ToString()));
}

Thanks,
The Web Platform and Tools Team

Modificato da manuel0081 il 22 febbraio 2006 16.41 -

Ormai programmano tutti... ma la professionalità appartiene a pochi

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.