Pregunta

I have control that inherited from ITemplate Interface. Data is displayed in HtmlTable control, that automatically generated on control initialization. Each row contain ImageButton controls that represent standard command (Edit, Delete, etc). Here code for creating ImageButton with standard command and adding it to row template:

var lkbCancel = new ImageButton()
{
    CommandName = "Edit",
    ImageUrl = "EditIco.png",
    ToolTip = "Edit",
    CausesValidation = false,
};

commandCell.Controls.Add(lkbCancel);

I would like to add ImageButton with custom command (not standard commands Add, Edit, Delete and other). So, how to add custom command and handle it correctly in Itemplate control?

¿Fue útil?

Solución

Just subscribe to the click event ?

lkbCancel.Click += (sender,e) => {
    //Do something here..
};

You can get access to the current data item that is bound to the row, see here

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top