2012-12-06 5 views
0

나는 다른 시리즈가있는 막 대형 차트가 있습니다. 각 시리즈는 다른 페이지를 가리켜 야합니다. URL을 제공하고 있습니다.이 오류가 있습니다.인덱스가 범위를 벗어났습니다. 음수가 아니어야하며 콜렉션의 크기보다 작아야합니다. 매개 변수 이름 : 색인

Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

Source Error:

Line 133:series1.Points[i].MapAreaAttributes = "Target=\"_blank\""; Line 134:series1.Points[0].Url = "db_PMUKPI_ByRM.aspx?Month=" + iMonth + "&Year=" + iYear; Line 135:series1.Points[1].Url = "db_PmuKpi_AllMonths.aspx?Month=" + iMonth + "&Year=" + iYear; Line 136:series1.Points[2].Url = "db_PmuKpi_AllMonths.aspx?Month=" + iMonth + "&Year=" + iYear; Line 137:series1.Points[3].Url = "db_PmuKpi_Overall_DateRange.aspx?Month=" + iMonth + "&Year=" + iYear;

+4

무엇 불분명하다 : - 인덱스는 일반적으로 0에서 시작하여 객체의 수에 종료 기억 당신이 for..loop를 사용하는 경우 1. 그래서,이 방법을 오류 메시지에 대해? – McGarnagle

답변

1

실제 코드를 보지 않고 루프의 일종을 사용하고 있고 루프 133이 루프 내부에 있다고 가정합니다. 당신이 series1.Points [i]에 접근하려고 시도하고있는 것처럼 보입니다, 나는 지수가됩니다.

int numItems = series1.Points.Count(); 
for (int i = 0; i < numItems; i++) 
{ 
series1.Points[i].MapAreaAttributes = "Target=\"_blank\""; 
} 
0

의 GridView없는 Datakeyname = "ID"

관련 문제