DataGrid.ItemCommand

  • Thread starter Thread starter - Steve -
  • Start date Start date
S

- Steve -

I'm really struggling with connecting the code for a PushButton on my
datagrid.

On the aspx file I have the following code:
<asp:ButtonColumn Text="Create User" ButtonType="PushButton"
CommandName="createUser"></asp:ButtonColumn>

Then on the codebehind file (C# by the way)

private void InitializeComponent()
{
this.dgNewUsers.ItemCommand += new
System.EventHandler(this.dgNewUsers_ItemCommand);
}

private void dgNewUsers_ItemCommand(object source,
System.Web.UI.WebControls.DataListCommandEventArgs e)
{
..... my code
}

However it won't compile becuase dgNewUsers_ItemCommand does not match
delegate. What did I do wrong?
 
Hi Steve,

By examining the code you provided I found that your event handler
is for DataList.
If you have a datagrid the event handler codelook like

private void dgNewUsers_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)

{

// code here


}

System.Web.UI.WebControls.DataListCommandEventArgs , this is for
ItemCommand event handler for DataList..

Hope this helps.

Regards,

Marshal Antony

..NET Developer

http://www.dotnetmarshal.com
 
Back
Top