[英]Dynamically created Radiobutton list not firing onselected
There is a dynamically created radiolist button and the aim is to fire an even when the radio button is clicked. 有一个动态创建的radiolist按钮,目的是在单击单选按钮时触发。 This is in a panel pnldynamic 这是一个动态面板
pnldynamic.Controls.Add(lbl);
RadioButtonList rd = new RadioButtonList();
foreach (CustomerFile cu in allCustomerFile)
{
rd.Items.Add(cu.ApplicationNumber.ToString());
}
rd.AutoPostBack = true;
rd.SelectedIndexChanged += new EventHandler(radioButton_CheckedChanged);
pnldynamic.Controls.Add(rd);
Following is the eventhandler for radiobuttonlist on selectedindex change 以下是关于选定索引更改的radiobuttonlist的事件处理程序
private void radioButton_CheckedChanged(object sender, EventArgs e)
{
RadioButton btn = sender as RadioButton;
txtReferenceNumber.Text = btn.Text;
}
The breakpoint in the function is not getting hit when the radiobuttonlist is selected 选择radiobuttonlist时,函数中的断点不会被击中
Try this: 尝试这个:
RadioButtonList rd = new RadioButtonList();
foreach (CustomerFile cu in allCustomerFile
{
rd.Items.Add(cu.ApplicationNumber.ToString());
}
rd.AutoPostBack = true;
rd.SelectedIndexChanged += new EventHandler(radioButton_CheckedChanged);
pnldynamic.Controls.Add(rd);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.