문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top