CheckBoxList选择其中一项其他自动清空 本帖最后由 chjyezi 于 2012-06-27 18:03:05 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果“无”是最后一项: <asp:CheckBoxList ID="CheckBoxList3" runat="server" AutoPostBack="True" onselectedindexchanged="CheckBoxList3_SelectedIndexChanged"> <asp:ListItem>耳机</asp:ListItem> <asp:ListItem>充电器</asp:ListItem> <asp:ListItem>电池</asp:ListItem> <asp:ListItem>无</asp:ListItem> </asp:CheckBoxList> protected void CheckBoxList3_SelectedIndexChanged(object sender, EventArgs e) { if (CheckBoxList3.Items[CheckBoxList3.Items.Count - 1].Selected) for (int i = 0; i < CheckBoxList3.Items.Count - 1; i++) CheckBoxList3.Items[i].Selected = false; } AutoPostBack="True" 去掉,这个是选择后自动回发,所以会刷新 把它放到 无刷新那ajax控件上 肯定得刷新 你用的是后台 代码 来控制前台,当你 后台代码执行完后,必须重新加载页面,才能显示出你后台代码实现的效果,要达到不刷新就的用JS 来控制的,JS 是前台,也就是客户端 运行的, 要无刷新的改成这样: <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:CheckBoxList ID="CheckBoxList3" runat="server" AutoPostBack="True" OnSelectedIndexChanged="CheckBoxList3_SelectedIndexChanged"> <asp:ListItem>耳机</asp:ListItem> <asp:ListItem>充电器</asp:ListItem> <asp:ListItem>电池</asp:ListItem> <asp:ListItem>无</asp:ListItem> </asp:CheckBoxList> </ContentTemplate> </asp:UpdatePanel> </form> 表单中其他select还是像闪屏一样。如何解决? Asp.net页面中如何将一个段Html源代码的String显示到页面一部分上 (急)GridView中手写绑定数据,如何简单快速进行分页 BS一下VS2005 Javascript动态组织URL 如何用客户端JavaScript脚本设定服务器端控件的ToolTip属性? 一个关于excel操作很急的问题,谢谢大家了 求助,怎样在一个购物网站中点击一按扭可以收藏该页 关于数据库主键的问题? DataGrid数据帮定 有关数据库连接的问题 截取字符串的问题。。。 关于lambda表达式中group join的问题
<asp:CheckBoxList ID="CheckBoxList3" runat="server" AutoPostBack="True" onselectedindexchanged="CheckBoxList3_SelectedIndexChanged">
<asp:ListItem>耳机</asp:ListItem>
<asp:ListItem>充电器</asp:ListItem>
<asp:ListItem>电池</asp:ListItem>
<asp:ListItem>无</asp:ListItem>
</asp:CheckBoxList>
protected void CheckBoxList3_SelectedIndexChanged(object sender, EventArgs e)
{
if (CheckBoxList3.Items[CheckBoxList3.Items.Count - 1].Selected)
for (int i = 0; i < CheckBoxList3.Items.Count - 1; i++)
CheckBoxList3.Items[i].Selected = false;
}
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:CheckBoxList ID="CheckBoxList3" runat="server" AutoPostBack="True" OnSelectedIndexChanged="CheckBoxList3_SelectedIndexChanged">
<asp:ListItem>耳机</asp:ListItem>
<asp:ListItem>充电器</asp:ListItem>
<asp:ListItem>电池</asp:ListItem>
<asp:ListItem>无</asp:ListItem>
</asp:CheckBoxList>
</ContentTemplate>
</asp:UpdatePanel>
</form>