OVH Cloud OVH Cloud

la méthode ne correspond pas au délégué.

2 réponses
Avatar
grome
bonjour à tous,

J'ai un souci avec le code ci dessous. Pour résumer, j'ai une webform avec
un datagrid. J'ai mis en place du code pour rendre possible la modification
des données du datagrid. Seulement j'obtiens les erreurs suivantes à la
génération.

C:\Inetpub\wwwroot\AppliWebTest\publishers.aspx.cs(67): La méthode
'AppliWebTest.publishers.dgrTitles_CancelCommand(object,
System.Web.UI.WebControls.DataGridCommandEventArgs)' ne correspond pas au
délégué 'void System.EventHandler(object, System.EventArgs)'

Je ne comprends pas trop ce qui se passe ...

j'ai créé les procédure suivante dans la webform

void dgrTitles_EditCommand(object sender, DataGridCommandEventArgs e)
void dgrTitles_UpdateCommand(object sender, DataGridCommandEventArgs e)
void dgrTitles_CancelCommand(object sender, DataGridCommandEventArgs e)
Voilà ce que j'ai pour le initializeComponent

private void InitializeComponent()
{
this.dgrTitles.EditCommand += new
System.EventHandler(this.dgrTitles_EditCommand);
this.dgrTitles.CancelCommand += new
System.EventHandler(this.dgrTitles_CancelCommand);
this.dgrTitles.UpdateCommand += new
System.EventHandler(this.dgrTitles_UpdateCommand);
this.Load += new System.EventHandler(this.Page_Load);
}

2 réponses

Avatar
Roman
"grome" a écrit :

J'ai un souci avec le code ci dessous. Pour résumer, j'ai une webform avec
un datagrid. J'ai mis en place du code pour rendre possible la modification
des données du datagrid. Seulement j'obtiens les erreurs suivantes à la
génération.



Il faut créer un handler de type DataGridCommandEventHandler.

this.dgrTitles.CancelCommand += new
System.EventHandler(this.dgrTitles_CancelCommand);



Essayez comme ça:

this.dgrTitles.CancelCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgrTitles_CancelCommand);
Avatar
grome
en fait il fallait écrire ceci

private void InitializeComponent()

{

this.dgrTitles.SelectedIndexChanged += new
System.EventHandler(this.dgrTitles_SelectedIndexChanged);

this.dgrTitles.CancelCommand += new
DataGridCommandEventHandler(this.dgrTitles_CancelCommand );

this.dgrTitles.EditCommand += new
DataGridCommandEventHandler(this.dgrTitles_EditCommand);

this.dgrTitles.UpdateCommand += new
DataGridCommandEventHandler(this.dgrTitles_UpdateCommand);

this.Load += new System.EventHandler(this.Page_Load);

}



"grome" a écrit dans le message de news:
426f9369$0$14260$
bonjour à tous,

J'ai un souci avec le code ci dessous. Pour résumer, j'ai une webform avec
un datagrid. J'ai mis en place du code pour rendre possible la
modification des données du datagrid. Seulement j'obtiens les erreurs
suivantes à la génération.

C:InetpubwwwrootAppliWebTestpublishers.aspx.cs(67): La méthode
'AppliWebTest.publishers.dgrTitles_CancelCommand(object,
System.Web.UI.WebControls.DataGridCommandEventArgs)' ne correspond pas au
délégué 'void System.EventHandler(object, System.EventArgs)'

Je ne comprends pas trop ce qui se passe ...

j'ai créé les procédure suivante dans la webform

void dgrTitles_EditCommand(object sender, DataGridCommandEventArgs e)
void dgrTitles_UpdateCommand(object sender, DataGridCommandEventArgs e)
void dgrTitles_CancelCommand(object sender, DataGridCommandEventArgs e)
Voilà ce que j'ai pour le initializeComponent

private void InitializeComponent()
{
this.dgrTitles.EditCommand += new
System.EventHandler(this.dgrTitles_EditCommand);
this.dgrTitles.CancelCommand += new
System.EventHandler(this.dgrTitles_CancelCommand);
this.dgrTitles.UpdateCommand += new
System.EventHandler(this.dgrTitles_UpdateCommand);
this.Load += new System.EventHandler(this.Page_Load);
}