我已經創建了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時= 「」;沒得到空
UPDATE
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 = "";
}
}
}
所以你有什麼問題? –
@Tianyun玲當我選擇第一個複選框,當我點擊兩個複選框都值disepears – Kriistiian
你檢查我的回答修改它顯示? –