我有一個配置文件,允許用戶顯示,編輯,保存。-C#標籤與文字不顯示值
保存和編輯工作正常。
但是,顯示器工作不正常。
我嘗試將標籤更改爲文字,但他們也沒有。
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.BindGenderDropDownList();
//this.BindTimeZonesDropDownList();
//this.BindCulturesDropDownList();
if (!string.IsNullOrEmpty(Membership.GetUser().UserName))
{
Profile = MyProfile.GetProfile(Membership.GetUser().UserName);
this.DisplayProfile();
}
}
}
protected void btnGo_Click(object sender, EventArgs e)
{
this.DisplayProfile();
}
protected void btnEdit_Click(object sender, EventArgs e)
{
this.EditProfile();
}
protected void btnCancelDisplay_Click(object sender, EventArgs e)
{
this.ResetElements();
}
protected void btnSave_Click(object sender, EventArgs e)
{
this.SaveProfile();
}
protected void btnCancelEdit_Click(object sender, EventArgs e)
{
this.ResetElements();
}
private void DisplayProfile()
{
this.SetElementsForDisplaying();
litfullname.Text = this.Profile.ProfileDetail.FullName;
}
private void EditProfile()
{
this.SetElementsForEditing();
if (Profile.ProfileDetail == null)
{
txtfname.Text = this.Profile.ProfileDetail.FullName;
txtcardno.Text = this.Profile.ProfileDetail.IdentityCardNo;
ddlcardcolor.SelectedValue = this.Profile.ProfileDetail.IdentityCardColour;
txtcardexp.Text = this.Profile.ProfileDetail.IdentityCardExpiryDate.ToString("dd MMMM yyyy");
ddlrace.Text = this.Profile.ProfileDetail.Race;
ddlreligion.SelectedValue = this.Profile.ProfileDetail.Religion;
txtaddress1.Text = this.Profile.ProfileDetail.ContactInformation.Address1;
txtaddress2.Text = this.Profile.ProfileDetail.ContactInformation.Address2;
txtaddress3.Text = this.Profile.ProfileDetail.ContactInformation.Address3;
txtpostcode.Text = this.Profile.ProfileDetail.ContactInformation.Postcode;
ddldistrict.SelectedValue = this.Profile.ProfileDetail.ContactInformation.District;
txtphoneoffice.Text = this.Profile.ProfileDetail.ContactInformation.OfficePhone;
txtphonehome.Text = this.Profile.ProfileDetail.ContactInformation.HomePhone;
txtphonecell.Text = this.Profile.ProfileDetail.ContactInformation.MobilePhone;
txtemail.Text = this.Profile.ProfileDetail.ContactInformation.Email;
}
}
保存個人資料。這工作正常。
private void SaveProfile()
{
if (Profile.ProfileDetail == null)
{
this.Profile.ProfileDetail.FullName = txtfname.Text;
this.Profile.ProfileDetail.IdentityCardNo = txtcardno.Text;
this.Profile.ProfileDetail.IdentityCardColour = ddlcardcolor.SelectedValue;
this.Profile.ProfileDetail.IdentityCardExpiryDate = DateTime.ParseExact(txtcardexp.Text, "dd MMMM yyyy", null);
this.Profile.ProfileDetail.Race = ddlrace.SelectedValue;
this.Profile.ProfileDetail.Religion = ddlreligion.SelectedValue;
this.Profile.ProfileDetail.ContactInformation.Address1 = txtaddress1.Text;
this.Profile.ProfileDetail.ContactInformation.Address2 = txtaddress2.Text;
this.Profile.ProfileDetail.ContactInformation.Address3 = txtaddress3.Text;
this.Profile.ProfileDetail.ContactInformation.Postcode = txtpostcode.Text;
this.Profile.ProfileDetail.ContactInformation.District = ddldistrict.SelectedValue;
this.Profile.ProfileDetail.ContactInformation.OfficePhone = txtphoneoffice.Text;
this.Profile.ProfileDetail.ContactInformation.HomePhone = txtphonehome.Text;
this.Profile.ProfileDetail.ContactInformation.MobilePhone = txtphonecell.Text;
this.Profile.ProfileDetail.ContactInformation.Email = txtemail.Text;
}
this.Profile.Save();
this.ResetElements();
}
要顯示,它不能正常工作
private void SetElementsForDisplaying()
{
pnlDisplayValues.Visible = true;
pnlSetValues.Visible = false;
litUserTitle.Visible = false;
litUserTitle.Text = string.Format("Display profile for {0}", this.Profile.UserName);
}
修改個人資料。正常工作 私人無效SetElementsForEditing() {
pnlDisplayValues.Visible = false;
pnlSetValues.Visible = true;
litUserTitle.Visible = true;
litUserTitle.Text = string.Format("Edit profile for {0}", this.Profile.UserName);
}
private void ResetElements()
{
pnlSetValues.Visible = false;
pnlDisplayValues.Visible = true;
litUserTitle.Visible = true;
}
解釋一下你的'工作不正常是什麼意思'? – Damith
標籤/文字不顯示數據。奇怪,因爲當我點擊編輯。數據仍然存在。 :/ – Belzelga