StartIndex 不能小于零。参数名称:startIndex 使用 HijriDatePicker?
StartIndex cannot be less than zero. Parameter name: startIndex Using HijriDatePicker?
我正在使用带有 gridview 控件的 Hijri Gregorian Datepicker 的许多实例,当我从 gridview 中删除时,我收到以下错误:
StartIndex cannot be less than zero.
Parameter name: startIndex
Line 173: //to manage multiple instances of user control postback, incase the postback happend due to culture changeed in current control,
Line 174: //the other user contrls culture drop down list to be changed accordingly. Also year and month dropdown lists according to culture
Line 175: if (strPostBackControlName != "" && strPostBackControlName.Substring(strPostBackControlName.LastIndexOf("$")) == "$ddlLocaleChoice")
Line 176: {
Line 177: if (ddlLocaleChoice.SelectedValue == arabicCulture.Name)
[ArgumentOutOfRangeException: StartIndex cannot be less than zero.
Parameter name: startIndex]
System.String.Substring(Int32 startIndex, Int32 length) +13011515
System.String.Substring(Int32 startIndex) +15
Hijri_Greg_DatePicker_Sample.HijriGregDatePicker.Page_Load(Object sender, EventArgs e) in C:\Users\Mawni\Desktop\Hijri_Greg_DatePicker_Sample\HijriGregDatePicker.ascx.cs:175
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +95
System.Web.UI.Control.LoadRecursive() +59
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678
有帮助吗?
看这段代码:
strPostBackControlName.LastIndexOf("$")
它将 return 字符串中 $
的最后一个索引,但是当未找到 $
时,它将 return -1
作为结果。稍后您将尝试使用此结果调用 strPostBackControlName.Substring
,但 Substring
具有以下原型:
public string Substring (int startIndex);
当然不能用小于 0 的起始索引调用它(因为字符串中的索引从 0
开始)。添加检查 LastIndexOf("$")
不是 -1
或确保 strPostBackControlName
始终包含 $
。
我正在使用带有 gridview 控件的 Hijri Gregorian Datepicker 的许多实例,当我从 gridview 中删除时,我收到以下错误:
StartIndex cannot be less than zero.
Parameter name: startIndex
Line 173: //to manage multiple instances of user control postback, incase the postback happend due to culture changeed in current control,
Line 174: //the other user contrls culture drop down list to be changed accordingly. Also year and month dropdown lists according to culture
Line 175: if (strPostBackControlName != "" && strPostBackControlName.Substring(strPostBackControlName.LastIndexOf("$")) == "$ddlLocaleChoice")
Line 176: {
Line 177: if (ddlLocaleChoice.SelectedValue == arabicCulture.Name)
[ArgumentOutOfRangeException: StartIndex cannot be less than zero.
Parameter name: startIndex]
System.String.Substring(Int32 startIndex, Int32 length) +13011515
System.String.Substring(Int32 startIndex) +15
Hijri_Greg_DatePicker_Sample.HijriGregDatePicker.Page_Load(Object sender, EventArgs e) in C:\Users\Mawni\Desktop\Hijri_Greg_DatePicker_Sample\HijriGregDatePicker.ascx.cs:175
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +95
System.Web.UI.Control.LoadRecursive() +59
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678
有帮助吗?
看这段代码:
strPostBackControlName.LastIndexOf("$")
它将 return 字符串中 $
的最后一个索引,但是当未找到 $
时,它将 return -1
作为结果。稍后您将尝试使用此结果调用 strPostBackControlName.Substring
,但 Substring
具有以下原型:
public string Substring (int startIndex);
当然不能用小于 0 的起始索引调用它(因为字符串中的索引从 0
开始)。添加检查 LastIndexOf("$")
不是 -1
或确保 strPostBackControlName
始终包含 $
。