I have the follwing class (Template), which inherits from UserControl. It contains a DataList with an ItemTemplate that among other things adds an ImageButton control to the container.
The Template user control itself is used in a third party datagrid called HierarGrid ( http://aspalliance.com/articleViewer.aspx?aId=21&pId=
). The basic idea is that this UserControl is used as a template to display related data for each row in a standard datagrid, in a drop-down format. The important things here is that the method OnDataTableDataBind() is called for each item of the primary datagrid on DataBinding of the user control, and has an argument that contains a DataTable that represents the child data for that item.
The following code is obviously a cut-down version, but the problem that I am having is that when you click on the ImageButton. The ItemCommand event of the DataList is not firing.
public class Template : System.Web.UI.UserControl
protected override void OnInit(EventArgs e)
+= new System.Web.UI.WebControls.
private void DataList1_ItemCommand(obje
ct sender, DataListCommandEventArgs args)
... // DOES NOT FIRE
// CALLED ON DataBinding ...
protected override void OnDataTableDataBind(Expand
DataList1.ItemTemplate = new DatalistLabelColumn();
DataList1.DataSource = args.Table;
public class DatalistLabelColumn : ITemplate
public void InstantiateIn(Control container)
ImageButton imgAdd = new ImageButton();
imgAdd.CommandName = "Add";
imgAdd.ImageUrl = @"~/image.gif";
Can anyone think of anything that could cause this?