日期:2014-05-18 浏览次数:20413 次
protected void btn_Search_Click(object sender, EventArgs e)//查询按钮事件 { List<Staff> list = new StaffManager().GetStaffDCN(staff);//查询用户 foreach (Staff sta in list) { CheckBox cb = new CheckBox();//创建CheckBox控件 cb.ID = sta.StfCode;//将员工编号设为ID cb.Text = sta.StfName; this.pnl_ToUser.Controls.Add(cb); //将控件添加入Panel中,在这里断点调试Count数为3 ! } } protected void btn_Save_Click(object sender, EventArgs e)//保存按钮事件 { List<MessageToUser> list = new List<MessageToUser>(); foreach (Control con in this.pnl_ToUser.Controls) //断点调试时这里Count却为1? { if (con is CheckBox) { CheckBox cb = con as CheckBox; if (cb.Checked) { MessageToUser messageToUser = new MessageToUser(); messageToUser.ToUserId = new Staff { StfCode=cb.ID }; list.Add(messageToUser); } } } }