SelectedIndexChanged for multiple RadionButtonList
本文关键字:RadionButtonList multiple for SelectedIndexChanged | 更新日期: 2023-09-27 18:12:26
我有3个RadionButtonList连接到相同的SelectedIndexChanged事件,故意的。是否有一种方法来确定在事件中,RadioButtonList只是有一个项目点击编程?
你可以使用你的RadioButtonList对象的ID
属性来做到这一点,只要获得sender
对象的ID事件被触发
protected void RadioButtonList_SelectedIndexChanged(object sender, EventArgs e)
{
string listName = ((RadioButtonList)sender).ID
// listName = RadioButtonList1 or RadioButtonList2 or whatever the ID is set to.
if (listName == "RadioButtonList1")
{
// Rest of your code goes here, now that you know which RadioButtonList the event was fired from
}
}