none
startIndex cannot be larger than length of string. RRS feed

  • Question

  • Hi ,

    I'm experience strange error which I'm unable to identify.

    below is the error

    startIndex cannot be larger than length of string.
    Parameter name: startIndex

    I don't have any substring that I'm applying for a string.

    Thanks in advance

    Abhilash

    Thursday, September 17, 2015 6:28 PM

Answers

  • Do you have a custom CheckBoxList control? If yes then you might want to check that the name of the control is similar to names of other controls; something like UniqueID followed by "$" and then the index at the end.

    I had similar issue times ago and that was the reason. I could not find the original site where this was explained, but I think it only applies to custom CheckBoxList controls.

    Monday, September 21, 2015 5:44 PM

All replies

  • What did you do to elicit that error message?
    Thursday, September 17, 2015 6:29 PM
  • Hi abhilash9,

    Have you debuged it? Where did the exception throw? Kindly post your related code.

    Best Regards,
    Li Wang

    Friday, September 18, 2015 8:07 AM
    Moderator
  • Yes Li Wang

    I have debugged the code but no clue.

    Below is the stack trace for your reference

    [ArgumentOutOfRangeException: startIndex cannot be larger than length of string.
    Parameter name: startIndex]
       System.String.Substring(Int32 startIndex, Int32 length) +12215063
       System.Web.UI.WebControls.CheckBoxList.LoadPostData(String postDataKey, NameValueCollection postCollection) +58
       System.Web.UI.WebControls.CheckBoxList.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +18
       System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +457
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1833

    Friday, September 18, 2015 6:08 PM
  • Do you have a custom CheckBoxList control? If yes then you might want to check that the name of the control is similar to names of other controls; something like UniqueID followed by "$" and then the index at the end.

    I had similar issue times ago and that was the reason. I could not find the original site where this was explained, but I think it only applies to custom CheckBoxList controls.

    Monday, September 21, 2015 5:44 PM