【问题标题】:Set an event on item select CheckboxList在项目选择 CheckboxList 上设置事件
【发布时间】:2011-05-11 16:03:28
【问题描述】:

如何根据 Checkboxlist (ASP.net 3.5) 中的选定项触发事件,Checkboxlist 中的 OnSelectedIndexChanged 返回所有选定项的列表,我只需要知道当前选定项。

【问题讨论】:

    标签: asp.net


    【解决方案1】:

    为什么复选框列表不会返回所有选中的复选框?复选框列表的本质是可以同时选择多个。

    如果您只需要一个项目,也许 radioButtonList 或 DropDownList 会更合适?

    http://msdn.microsoft.com/en-us/library/1wd7hsyy(v=VS.85).aspx

    Protected void DropDownList1_SelectedIndexChanged(object sender,
         System.EventArgs e)
    {
       Label1.Text = "You selected " + DropDownList1.SelectedItem.Text;
    }
    

    随意测试 CheckBoxList.SelectedItem,但措辞并没有明确表明它具有与 RadioButtonList 或 DropDownList 相同的功能。

    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listcontrol.selecteditem.aspx

    【讨论】:

    • 两者都继承自 System.Web.UI.WebControls.ListControl 并且可以共享此功能。 CheckBoxList 也可能是 ListControl 的错误选择。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-16
    相关资源
    最近更新 更多