SelectedIndexChanged for multiple RadionButtonList

本文关键字:RadionButtonList multiple for SelectedIndexChanged | 更新日期: 2023-09-27 18:12:26

我有3个RadionButtonList连接到相同的SelectedIndexChanged事件,故意的。是否有一种方法来确定在事件中,RadioButtonList只是有一个项目点击编程?

SelectedIndexChanged for multiple RadionButtonList

你可以使用你的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
    }
}
相关文章:
  • 没有找到相关文章