Server Error in '/' Application.

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 31: 		if (apt.Exists)
Line 32: 		{
Line 33: 	        MainImage.ImageUrl = "http://www.olr.com/broker/myolr/thumb.axd?url=" + apt.Pictures[0].MediaUrl + "&h=300";
Line 34: 	        MainImage.Height = 250;
Line 35: 	        for (int i = 0; i < apt.Pictures.Count; i++)

Source File: d:\Sites\Client\Glenmark\viewphoto.aspx.cs    Line: 33

Stack Trace:


[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index]
   System.Collections.CollectionBase.System.Collections.IList.get_Item(Int32 index) +10585492
   OLR.Library.Collection`1.get_Item(Int32 index) +43
   viewphoto.aptfunction() in d:\Sites\Client\Glenmark\viewphoto.aspx.cs:33
   viewphoto.Page_Load(Object sender, EventArgs e) in d:\Sites\Client\Glenmark\viewphoto.aspx.cs:23
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42
   System.Web.UI.Control.OnLoad(EventArgs e) +132
   System.Web.UI.Control.LoadRecursive() +66
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428


Version Information: Microsoft .NET Framework Version:2.0.50727.9061; ASP.NET Version:2.0.50727.9062