我正在创建一个 WebForm,其中提供了启用和禁用文本框的功能。但是,当我在 TextBox 中输入值然后禁用它时。我无法将 TextBox 值保存在数据库中。每当代码尝试保存该值时,都会在其中获取一个空值,因此它存储一个空值。当我不禁用文本框时,该值会成功存储在表中。下面是一些与之相关的代码......
protected void btnCreateSubAcct_Click(object sender, EventArgs e)
{
int subAccountID = 0;
try
{
if (Page.IsValid)
{
subAccountID = SaveUpdateSubAccount();
if (string.IsNullOrEmpty(HiddenFieldSubAccntID.Value))
{
SessionHandler.Set(SessionHandler.SubAccountIDKey, subAccountID);
Response.Redirect("~/newaccountwelcome");
}
else
{
lblDialogMessage.Text = "Subaccount updated successfully!";
modalPage.Visible = true;
SetFocus(btnOK.ClientID);
}
}
}
catch (ThreadAbortException)
{
}
catch (Exception ex)
{
_log.Error("Error Occured While Creation of SubAccount.", ex);
throw;
}
}
private int SaveUpdateSubAccount()
{
SubAccount objSubAccount = null;
if (!string.IsNullOrEmpty(HiddenFieldSubAccntID.Value) && !HiddenFieldSubAccntID.Value.Equals("0"))
{
objSubAccount = SubAccount.GetSubAccount(Convert.ToInt32(HiddenFieldSubAccntID.Value));
}
if (objSubAccount == null)
{
objSubAccount = new SubAccount();
objSubAccount.CreatedByUser = SessionHandler.CurrentUser.UserID;
}
objSubAccount.FBO1FirstName = txtFBO1FirstName.Text.Trim();
objSubAccount.FBO1MiddleInitial = txtFBO1MiddleName.Text.Trim();
objSubAccount.FBO1LastName = txtFBO1LastName.Text.Trim();
objSubAccount.FBO1AccountTitling = txtFbo1AccountTitling.Text.Trim();
objSubAccount.FBO1TaxIDType = fbo1RadioButtonList.SelectedItem.Value;
objSubAccount.FBO1TaxID = Helpers.GetUnFormattedTIN(txtFbo1TaxId.Text.Trim());
}
//under the class SubAccount, the information is getting stored in the database
每当我尝试保存文本 FBO1TaxID 的值时,当它处于禁用模式时,此 TextBox 下的值是空的。
如何将禁用模式下的文本框的值保存在数据库表下?请帮忙!