我创建了一个Checkboxlist
和Button
两个TextBoxes
。
在选择checkboxes
和按下的第一个值时,button
我想在其中一个中显示它,textboxes
当我取消选中时,checkboxes
我希望该值从该值中消失textboxes
。
if (CheckBoxPersonalInfo.Items[0].Selected)
{
LabelFirstName.Text = CheckBoxPersonalInfo.Items[0].Text;
}
else
{
LabelFirstName.Text = "";
}
if (CheckBoxPersonalInfo.Items[1].Selected)
{
LabelLastName.Text = CheckBoxPersonalInfo.Items[1].Text;
}
else
{
LabelLastName.Text = "";
}
此代码工作正常,但取消选中 LabelFirstName.Text & LabelLastName.Text = ""; 不要空着
更新
private void ButtonOKCheckBoxes()
{
EMPLOYEE theEmpl;
using (var db = new knowitCVdbEntities())
{
theEmpl = (from p in db.EMPLOYEES
where p.username == strUserName
select p).FirstOrDefault();
}
if (theEmpl != null)
{
PanelFullCv.Visible = true;
LabelPleaseRegister.Visible = false;
//CheckBoxPersonalInfo.Items[0].Text;
if (CheckBoxPersonalInfo.Items[0].Selected)
{
LabelFirstName.Text = theEmpl.firstname;
}
else
{
LabelFirstName.Text = "";
}
//CheckBoxPersonalInfo.Items[1].Text;
if (CheckBoxPersonalInfo.Items[1].Selected)
{
LabelLastName.Text = theEmpl.lastname;
}
else
{
LabelLastName.Text = "";
}
}
}