Event problem

J

Jonas Karlsson

The following code gives a compile error:

Method myGrid_Edit(object,
System.Web.UI.WebControls.DataGridCommandEventArgs)' does not match delegate
'void System.EventHandler(object, System.EventArgs)'


When I change my eventhandler to instead of the DataGridCommandEventArgs
takes the EventArgs I get:

Cannot implicitly convert type 'System.EventHandler' to
'System.Web.UI.WebControls.DataGridCommandEventHandler'


My code:

DataGrid myGrid = new DataGrid();
myGrid.EditCommand += new EventHandler(myGrid_Edit);

public void myGrid_Edit(Object sender, DataGridCommandEventArgs e)
{
myGrid.EditItemIndex = e.Item.ItemIndex;
myGrid.DataBind();
}
 
J

Jonas Karlsson

I solved this problem myself, but I am surprised that I couldn't find the
answer here...

The trick is to use
GridDays.EditCommand += new DataGridCommandEventHandler(GridDays_Edit);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,137
Messages
2,570,797
Members
47,345
Latest member
tektheone

Latest Threads

Top