Yes, you have to use CommandName or Command Argument.
ImageButton btn = new ImageButton();
btn.CommandName = "xx";
protected void myItemCommand(...)
if(e.CommandName == "xx")
// your code
The Best Regards,
"KJ" <klj_mcsdhotmail.com> wrote in message
news:d83a9214.0312151331.3f70a4b6posting.google.c om...> I create a datagrid and at runtime I add an ImageButton to certain
> cells(e.Item.Cells.Controls.Add(imgbutton)). Now when I click on a row
> that contain an image button, in the ItemCommand event the row is
> So I do e.Item.Cells(3) is the cell with the control in it supposely.
> When I do e.Item.Cells.Controls.Count it returns 0. Why? How can I
> tell if I clicked on a row with an imagebutton in cell 3?