【问题标题】:SelectedIndexChanged for multiple RadionButtonList多个 RadionButtonList 的 SelectedIndexChanged
【发布时间】:2015-09-10 23:29:19
【问题描述】:

我有 3 个 RadionButtonList 有意连接到同一个 SelectedIndexChanged 事件。有没有办法确定哪个 RadioButtonList 刚刚以编程方式点击了其中一个项目?

【问题讨论】:

  • 查看属性 -> 事件

标签: c# asp.net radiobuttonlist selectedindexchanged


【解决方案1】:

您可以使用 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
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-10
    相关资源
    最近更新 更多