Cliquer deux fois pour lancer le onclick d'un Imagebutton dans un datagrid
Je reviens à la charge avec un problème que je n'arrive pas à résoudre.
J'ai un moteur de recherche qui effectue donc une requete lorsqu'on clique sur un des boutons de recherche pour ensuite afficher un datagrid, qui contient des Imagebuttons.
Mon problème est que je suis obligé de cliquer 2 fois qur les imagebutton pour que l'évènement onclick (qui ouvre une popup) se lance.8O
La première fois, rien ne se passe à part qu'il y a (il me semble) un rafraichissement de la page ou du datagrid sans changer les données.
Au deuxième clic, c'est bon.
Je n'ai pas toruvé de solution et je deviens zinzin :aie: lol
Voici mon code pour le datagrid et un imagebutton :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
<asp:DataGrid id="Datagrid1" runat="server" AllowPaging="true" AllowSorting="true" Visible="true" ShowHeader="true" BackColor="#efefef" AlternatingItemStyle-BackColor="#ffffff" BorderColor="#a9a9a9" BorderStyle="Solid" BorderWidth="1px" ItemStyle-Height="40px" Width="940px" AutoGenerateColumns="false">
<COLUMNS>
<ASP:TEMPLATECOLUMN>
<ITEMTEMPLATE>
<ASP:IMAGEBUTTON id="IMGsupp" Runat="server" AlternateText="Supprimer la D.A" ImageUrl='<%# ChangeImageSupprimeDA(DataBinder.Eval(Container,"DataItem.Numero_DA")& "|" &DataBinder.Eval(Container,"DataItem.Service_1")& "|" &DataBinder.Eval(Container,"DataItem.Service_2")& "|" &DataBinder.Eval(Container,"DataItem.Demandeur")& "|" &DataBinder.Eval(Container,"DataItem.Validee")& "|" &DataBinder.Eval(Container,"DataItem.Date_validation"))%>' CommandArgument='<%# DataBinder.Eval(Container,"DataItem.Numero_DA")& "|" &DataBinder.Eval(Container,"DataItem.Service_1")& "|" &DataBinder.Eval(Container,"DataItem.Service_2")& "|" &DataBinder.Eval(Container,"DataItem.Demandeur")& "|" &DataBinder.Eval(Container,"DataItem.Validee")& "|" &DataBinder.Eval(Container,"DataItem.Date_validation")%>' OnCommand="SupprimeDA">
</ASP:IMAGEBUTTON>
</ITEMTEMPLATE>
</ASP:TEMPLATECOLUMN>
</COLUMNS>
<HeaderStyle BackColor="#e6e6e6" ForeColor="Black" Font-Size="12pt" Font-Bold="True" HorizontalAlign="Center" />
<PagerStyle BackColor="#e6e6e6" ForeColor="Black" Font-Size="8pt" Font-Bold="True" HorizontalAlign="Right" Mode="NumericPages" Position="TopAndBottom" PageButtonCount="10" />
</asp:DataGrid> |
Et voici la fonction que j'appelle pour ouvrir la fenetre et supprimer un enregistrement pour le premier ImageButton:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
Public Sub SupprimeDA(ByVal monobject As System.Object, _
ByVal e As System.Web.UI.WebControls.CommandEventArgs)
TBLResultat.Visible = False
TBLInfos.Visible = False
Dim ServDemandeur As String
Dim NomPrenom As String
Dim SepareVar
Dim VarNumero_DA
Dim VarService_1
Dim VarService_2
Dim VarDemandeur
Dim VarValidee
Dim VarDate_validation
'recupère les informations nécessaires en les séparant d'après le caractère "|"
SepareVar = Split(monobject.CommandArgument, "|")
VarNumero_DA = SepareVar(0)
VarService_1 = SepareVar(1)
VarService_2 = SepareVar(2)
VarDemandeur = SepareVar(3)
VarValidee = SepareVar(4)
VarDate_validation = SepareVar(5)
VerifiSignataires(monobject.CommandArgument, Nom & " " & Prenom)
'If (Direction = "A" Or Direction = "CG" _
If (Direction = "A" _
Or NomPrenom.Concat(Nom & " " & Prenom) = VarDemandeur) _
And monobject.ImageURL = "img/supprimer.gif" Then
monobject.Attributes("onClick") = "javascript:" & _
"window.open('Suppression.aspx?num=" & VarNumero_DA & "','fullscreen');return(false)"
End If
End Sub |
Merci d'avance si vous avez une solution.
@ bientôt