日期:2014-05-18  浏览次数:20429 次

求救,checkboxlist如何随点随变
checkboxlist如何随点随时使文本框里的内容变,就是指选中与不选中
谢谢!!!

------解决方案--------------------
把文本内容变化的代码写到控件选中与否的事件里,当checkboxlist状态改变时触发事件就执行文本内容变化。
------解决方案--------------------
1 JS

2 将CheckBoxList的AutoPostBack属性选为True,这样每当勾选CheckBoxList里的CheckBox,都会触发后台事件。想怎么做,在事件里写吧。
------解决方案--------------------
前台[
code=C#]
 <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" 
oncheckedchanged="CheckBox1_CheckedChanged" Text="没选" />
[/code]
后台
C# code

 protected void  CheckBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (CheckBox1.Checked == true)
            {
                CheckBox1.Text = "选中";
            }
            else
            {
                CheckBox1.Text = "没选";
            }
        }

------解决方案--------------------
CheckBoxList的话这样
前台
C# code

 <asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="True" 
        onselectedindexchanged="CheckBoxList1_SelectedIndexChanged">
        <asp:ListItem Value="1">没选</asp:ListItem>
        <asp:ListItem Value="2">没选</asp:ListItem>
        <asp:ListItem Value="3">没选</asp:ListItem>
        <asp:ListItem Value="4">没选</asp:ListItem>
    </asp:CheckBoxList>