我一直认为要减,但是今天我却发现不减才才对,代码如下
========html页================
<asp:CheckBoxList id=chk style="Z-INDEX: 101; LEFT: 208px; POSITION: absolute; TOP: 96px" runat="server">
<asp:ListItem Value="1111">1111</asp:ListItem>
<asp:ListItem Value="222">222</asp:ListItem>
<asp:ListItem Value="3333">3333</asp:ListItem>
<asp:ListItem Value="444444">4444</asp:ListItem>
<asp:ListItem Value="5555">5555</asp:ListItem>
</asp:CheckBoxList>
<asp:Button id=Button1 style="Z-INDEX: 102; LEFT: 208px; POSITION: absolute; TOP: 240px" runat="server" Text="Button"></asp:Button>
===========.cs页==============
for(int i=0;i<this.chk.Items.Count-1;i++)
if (this.chk.Items[i].Selected)
{
Response.Write(this.chk.Items[i].Text+"<br>");
}
==============完===================
如果减1的话,那么最后一项就显示不出来!
========html页================
<asp:CheckBoxList id=chk style="Z-INDEX: 101; LEFT: 208px; POSITION: absolute; TOP: 96px" runat="server">
<asp:ListItem Value="1111">1111</asp:ListItem>
<asp:ListItem Value="222">222</asp:ListItem>
<asp:ListItem Value="3333">3333</asp:ListItem>
<asp:ListItem Value="444444">4444</asp:ListItem>
<asp:ListItem Value="5555">5555</asp:ListItem>
</asp:CheckBoxList>
<asp:Button id=Button1 style="Z-INDEX: 102; LEFT: 208px; POSITION: absolute; TOP: 240px" runat="server" Text="Button"></asp:Button>
===========.cs页==============
for(int i=0;i<this.chk.Items.Count-1;i++)
if (this.chk.Items[i].Selected)
{
Response.Write(this.chk.Items[i].Text+"<br>");
}
==============完===================
如果减1的话,那么最后一项就显示不出来!