如何进行加法运算?

lincong1978 2008-07-25 09:18:07

就是我选一个工作人员,底下的共几人就加1 .我不选一个工作人员,底下的共几人就减1.

代码:
protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
{
for (int i = 1; i < this.CheckBoxList1.Items.Count;i++ )
{
if (CheckBoxList1.Items[i].Selected)
{
int n1 = Convert.ToInt16(txtGzrys.Text);
n1 = n1 + 1;
txtGzrys.Text = n1.ToString();
}
}
}
...全文
107 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
cononlove 2008-07-25
  • 打赏
  • 举报
回复
学习
lincong1978 2008-07-25
  • 打赏
  • 举报
回复
正确答案:
protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
{
int selectCount = 0;
for (int i = 0; i < this.CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected)
{
selectCount++;
txtGzrys.Text = selectCount.ToString();
}
}
}
lincong1978 2008-07-25
  • 打赏
  • 举报
回复
这样还是不对的。[Quote=引用 6 楼 zhouchenguang 的回复:]
for (int i = 0; i < this.CheckBoxList1.Items.Count;i++ )
[/Quote]
zhouchenguang 2008-07-25
  • 打赏
  • 举报
回复
for (int i = 0; i < this.CheckBoxList1.Items.Count;i++ )
lincong1978 2008-07-25
  • 打赏
  • 举报
回复
具体点行吗?谢谢。[Quote=引用 1 楼 falx2004 的回复:]
text = selectedItems.cout
不行?
[/Quote]
lincong1978 2008-07-25
  • 打赏
  • 举报
回复
光这样不行。
[Quote=引用 2 楼 lff 的回复:]
下标从0开始,囧

int i = 0;
[/Quote]
lincong1978 2008-07-25
  • 打赏
  • 举报
回复
具体点??
lff 2008-07-25
  • 打赏
  • 举报
回复
下标从0开始,囧

int i = 0;
falx2004 2008-07-25
  • 打赏
  • 举报
回复
text = selectedItems.cout
不行?

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧