Index is out of range.A non-negative value must be less than the size of the collection.

Asked 1 years ago, Updated 1 years ago, 439 views

After implementing the following code, the error started to follow the title.
I couldn't solve the problem even after looking into it, so I'll ask you a question.
I look forward to hearing from anyone I know.

protected bool IsShippingPatternChanged (int index)
{return(m_lFixedPurchaseFirstPatternStrings[index]!="")&(m_lFixedPurchaseFirstPatternStrings[index]!=m_lFixedPurchasePatternStrings[index])));}

Add: IsShippingPatternChanged is being called.

<dlvisible="<%#m_lFixedPurchaseFlgs [Container.ItemIndex]%>"runat="server">;;
    <dt visible='<%#IsShippingPatternChanged(Container.ItemIndex)%>'runat="server">First Delivery Pattern:</dt>
    <dd visible='<%#IsShippingPatternChanged(Container.ItemIndex)%>'runat="server"><%#:WebSanitizer.HtmlEncode(m_lFixedPurchaseFirstPatternString [Container.ItemIndex]>%dt;
    <dt visible='<%#IsShippingPatternChanged(Container.ItemIndex)%>'runat="server">2nd and subsequent delivery patterns:</dt>
    <dt visible='<%#IsShippingPatternChanged(Container.ItemIndex)==false%>'runat="server">Delivery pattern:</dt>

c#

2023-02-13 07:11

1 Answers

If there are exceptions in this section,
Collection refers to m_lFixedPurchaseFirstPatternStrings and
The index refers to [], or index.

index is a non-negative value and must be less than the size of m_lFixedPurchaseFirstPatternStrings
Either the index is negative or the size of the m_lFixedPurchaseFirstPatternString is greater than or equal to the size of the m_lFixedPurchaseFirstPatternString.

index is not determined in IsShippingPatternChanged, but
I am calling IsShippingPatternChanged.
So you need to look at the code for the part calling IsShippingPatternChanged.


2023-02-13 19:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.