【发布时间】:2015-09-10 23:29:19
【问题描述】:
我有 3 个 RadionButtonList 有意连接到同一个 SelectedIndexChanged 事件。有没有办法确定哪个 RadioButtonList 刚刚以编程方式点击了其中一个项目?
【问题讨论】:
-
查看属性 -> 事件
标签: c# asp.net radiobuttonlist selectedindexchanged
我有 3 个 RadionButtonList 有意连接到同一个 SelectedIndexChanged 事件。有没有办法确定哪个 RadioButtonList 刚刚以编程方式点击了其中一个项目?
【问题讨论】:
标签: c# asp.net radiobuttonlist selectedindexchanged
您可以使用 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
}
}
【讨论】: