RadioButtonList Inside Repeater OnSelectedIndexCha

2019-08-05 16:26发布

I have a RadioButtonList inside a Repeater. I have AutoPostback set to "true" and the OnSelectedIndexChanged defined. When I selected a different radiobutton in my list the page does postback, but my defined OnSelectedIndexChanged event is not catching or firing. Not sure what I am missing. Here is my markup and codebehind:

screenshot

1条回答
叛逆
2楼-- · 2019-08-05 16:59

Use the repeater's itemcreated event to bind your eventhandler:

 protected void Repeater!_ItemCreated(object sender, RepeaterItemEventArgs e)
        {
                if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
                {
                   e.item.FindControl("TaskRadioButtonList").SelectedIndexChanged += new EventHandler(TaskRadioButtonList_OnSelectedIndexChanged);

                }
        }
查看更多
登录 后发表回答