ImageButton in ASP.NET Repeater does not fire OnClick eventhandler

后端 未结 2 757
栀梦
栀梦 2021-01-16 10:35

I have an ImageButton inside a repeater control. I have attached an eventhandler to the OnClick event of the ImageButton. But when I click the ImageButton the event does not

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-16 10:58

    I had det same problem, and solved it by using av asp:Linkbutton with a with the "OnCommand" event. My markup and code behind is posted below.

    Markup:

    
                
                    
                    
                    

    Code behind:

     protected void lbRemove_Command(object sender, CommandEventArgs e)
        {
            switch (e.CommandName)
            {
                case "Remove":
                    Recipients.Remove(e.CommandArgument.ToString());
                    rptRecipients.DataSource = Recipients;
                    rptRecipients.DataBind();
                    break;
    
            }
        }
    

提交回复
热议问题