?
Solved

Index out of range

Posted on 2004-09-21
3
Medium Priority
?
476 Views
Last Modified: 2012-08-13
   Public Sub ddlDate_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlDate.SelectedIndexChanged

        Dim ProgramName As String = ddlProgramName.SelectedItem.Text
        Dim myDate As String = ddlDate.SelectedItem.Text

        Dim CommandText As String = "SELECT DISTINCT Time FROM Logs WHERE ProgramName = '" & ProgramName & "' AND Date = '" & myDate & "'"

        ddlTime.DataSource = Get_Database_Values(CommandText)
        ddlTime.DataTextField = "Time"
        ddlTime.DataValueField = "Time"
        ddlTime.DataBind()

        ddlTime.Items.Insert(0, "--Select Time--")
        ddlTime.Items.Insert(1, "All")

        lblTime.Visible = True
        ddlTime.Visible = True

    End Sub

When I run this code I get an index out of range error,her eis hte stack trace:

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

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.ArrayList.get_Item(Int32 index) +91
   System.Web.UI.WebControls.ListItemCollection.get_Item(Int32 index) +10
   VaraibleEditor.LogViewer.ddlTime_SelectedIndexChanged(Object sender, EventArgs e) +627
   System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e) +108
   System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent() +26
   System.Web.UI.Page.RaiseChangedEvents() +115
   System.Web.UI.Page.ProcessRequestMain() +1099

 
Please help, I have been at work since 8 this morning and cant go home until this is done, and I am soooooo hungry (it is now 7:20 Pm :-( )
0
Comment
Question by:Wonderflub
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Expert Comment

by:w_shaila
ID: 12119117
In the Stack Trace you are getting error in ddlTime_SelectedIndexChanged not in ddlDate_SelectedIndexChanged.
Can you post what you have written in ddlTime_SelectedIndexChanged.
0
 

Accepted Solution

by:
Wonderflub earned 0 total points
ID: 12119127
hmmm, I had deleted this question.... but since it did not delete, I will answer how I correted the problem since when I searched I did not fidn this resolve.

I had neglected to databind my lbactive listbox, therefore there were no items in it at all
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question