以下是我的代碼,我聲明一個列爲私有字符串,我使用該值綁定到網格的值,但我得到的錯誤輸入字符串不正確的格式近「PolicyRenewalGracePeriodDays」 ..please看到高亮文本的下方,建議我請輸入字符串格式不正確
/// </summary>
private const string COL_UNDERWRITER_DISPLAY_NAME = "UnderwriterDisplayName";
/// <summary>
///
/// </summary>
private const string COL_UNDERWRITER_INITIALS = "UnderwriterInitials";
/// <summary>
///
/// </summary>
private const string COL_UA_DISPLAY_NAME = "UADisplayName";
/// <summary>
///
/// </summary>
private const string COL_UA_INITIALS = "UA";
**private const string COL_RENEWAL_GRACE_PERIOD_DAYS = "PolicyRenewalGracePeriodDays";**
#endregion
protected void grdAction_DataBound(object sender, EventArgs e)
{
foreach (UltraGridRow row in this.grdAction.DisplayLayout.Rows)
{
TemplatedColumn col;
CellItem item;
HyperLink docLink;
HyperLink letterLink;
HyperLink actionLink;
Label actionLabel;
var policyClassId = Utility.GetCurrentPolicyClassId();
PolicyClass policyClass = Utility.GetCurrentPolicyClassEntity();
var accountId = (int) row.DataKey;
var insuredName = row.Cells.FromKey(COL_INSURED_NAME_HIDDEN).Text;
var referenceNumber = row.Cells.FromKey(COL_REFERENCE_NUMBER).Text;
var statusId = int.Parse(row.Cells.FromKey(COL_STATUS_ID).Text);
var optionNames = string.Empty;
if (!string.IsNullOrEmpty(row.Cells.FromKey(COL_OPTION_NAMES).Text))
optionNames = row.Cells.FromKey(COL_OPTION_NAMES).Text;
var optionCount = int.Parse(row.Cells.FromKey(COL_OPTION_COUNT).Text);
var isVoidable = (row.Cells.FromKey(COL_IS_VOIDABLE).Text == "1");
bool renewalFlag;
bool doNotRenewFlag;
bool hasRenewingReferenceNumber;
var currentUser = (User) Session[AppConstants.SK_CURRENT_USER];
var expirationDate = DateTime.MinValue;
bool convertedFlag;
var documentCount = int.Parse(row.Cells.FromKey(COL_DOCUMENT_COUNT).Text);
var allowAddLayer = bool.Parse(row.Cells.FromKey(COL_ALLOW_ADD_LAYER).Text);
var renewableLayers = row.Cells.FromKey(COL_RENEWABLE_LAYERS).Text;
int renewalGracePeriodDays = 0;
**renewalGracePeriodDays = int.Parse(row.Cells.FromKey(COL_RENEWAL_GRACE_PERIOD_DAYS).Text);**
我的'row.Cells.FromKey(COL_RENEWAL_GRACE_PERIOD_DAYS).Text'包含字符,然後'0-9':) –
您需要識別'row.Cells.FromKey(COL_RENEWAL_GRACE_PERIOD_DAYS)的值。文本'在發生異常時。然後更新您的問題以包含該值。 –
'int.Parse(「thisIsNotAValidNumber」)'會拋出一個異常,就像你看到的那樣。檢查文本字符串是什麼。它可能是空的或包含字母或其他東西。 –