<%@ Page Language="C#" %>
<html>
<head><script language="C#" runat="server"> void Check_Clicked(Object sender, EventArgs e)
{
Message.Text = "Selected Item(s):<br><br>";
for (int i=0; i<checkboxlist1.Items.Count; i++)
{
if (checkboxlist1.Items[i].Selected)
Message.Text += checkboxlist1.Items[i].Text + "<br>";
}
}</script>
</head>
<body>
<form action="checkboxlist.aspx" method="post" runat="server">
<h3>CheckBoxList Example</h3> <asp:CheckBoxList id="checkboxlist1"
AutoPostBack="True"
CellPadding="5"
CellSpacing="5"
RepeatColumns="2"
RepeatDirection="Vertical"
RepeatLayout="Flow"
TextAlign="Right"
OnSelectedIndexChanged="Check_Clicked"
runat="server">
<asp:ListItem>Item 1</asp:ListItem>
<asp:ListItem>Item 2</asp:ListItem>
<asp:ListItem>Item 3</asp:ListItem>
<asp:ListItem>Item 4</asp:ListItem>
<asp:ListItem>Item 5</asp:ListItem>
<asp:ListItem>Item 6</asp:ListItem>
</asp:CheckBoxList>
<br><br> <asp:label id="Message" runat="server"/>
</form>
</body>
</html>
<html>
<head><script language="C#" runat="server"> void Check_Clicked(Object sender, EventArgs e)
{
Message.Text = "Selected Item(s):<br><br>";
for (int i=0; i<checkboxlist1.Items.Count; i++)
{
if (checkboxlist1.Items[i].Selected)
Message.Text += checkboxlist1.Items[i].Text + "<br>";
}
}</script>
</head>
<body>
<form action="checkboxlist.aspx" method="post" runat="server">
<h3>CheckBoxList Example</h3> <asp:CheckBoxList id="checkboxlist1"
AutoPostBack="True"
CellPadding="5"
CellSpacing="5"
RepeatColumns="2"
RepeatDirection="Vertical"
RepeatLayout="Flow"
TextAlign="Right"
OnSelectedIndexChanged="Check_Clicked"
runat="server">
<asp:ListItem>Item 1</asp:ListItem>
<asp:ListItem>Item 2</asp:ListItem>
<asp:ListItem>Item 3</asp:ListItem>
<asp:ListItem>Item 4</asp:ListItem>
<asp:ListItem>Item 5</asp:ListItem>
<asp:ListItem>Item 6</asp:ListItem>
</asp:CheckBoxList>
<br><br> <asp:label id="Message" runat="server"/>
</form>
</body>
</html>
解决方案 »
- 请教datetime转换问题
- C# 如何将正在运行的文件删除?
- Wcf 以前软件 现在更新一下服务 自定义工具错误
- 多个空格组成的一个字符串,如何表示呀?
- c# 日历控件 怎样把有数据的日期凸显出?
- SQL语句中的字段名可以动态的设置吗?
- 在线求教难题:从配置文件中取出多个方法名及程序集路径,将配置文件中的一组方法挂接到程序的某个事件上。即根据配置文件中的设置动态的绑定到程序的指定的事件上
- 在安装程序结束之前执行一个 .exe 程序
- 能不能对同一串口,如COM1口同时用多线程进行读写操作。例如一个线程读,一个同时写。
- 反射问题
- 那位大侠有Microsoft BizTalk 2000 下载地址,请提示
- 如果在VC#中调用Outlook Express来发信(在线等待)
string msg = this.checkedListBox1.GetItemCheckState(k).ToString();
MessageBox.Show(msg.ToString());2 返回当前Checked的所有项目string msg = "";
foreach(object checkeditem in this.checkedListBox1.CheckedItems)
{
msg += checkeditem.ToString() + " ";
}
MessageBox.Show(msg.ToString());