以下是我的代码,我声明一个列为私有字符串,我使用该值绑定到网格的值,但我得到的错误输入字符串不正确的格式近“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”)'会抛出一个异常,就像你看到的那样。检查文本字符串是什么。它可能是空的或包含字母或其他东西。 –