Hi,
To add a button alongside a data item in a cell, you can add this code snippet in the CustomTemplate class:
Label label = new Label();
label.ID = "TemplateLabel";
label.CssClass = "id-label";
label.Text = ((DataRowView)((TemplateContainer)container).DataItem)["id"].ToString();
container.Controls.Add(label);
Your InstantiateIn method in the CustomTemplate should look like this:
public void InstantiateIn(Control container)
{
Label label = new Label();
label.ID = "TemplateLabel";
label.CssClass = "id-label";
label.Text = ((DataRowView)((TemplateContainer)container).DataItem)["id"].ToString();
container.Controls.Add(label);
Button delete = new Button();
delete.ID = "TemplateButton";
delete.Text = "Delete";
delete.OnClientClick = "return deleteRow()";
container.Controls.Add(delete);
}
This way you are filling the container with a label that contains the respective id of the cell.
Here is a help topic for your reference – https://www.infragistics.com/help/aspnet/webdatagrid-refrence-a-cell-when-creating-an-item-template.
Regards,
Hristo Popov