Solved

Index out of range

Posted on 2004-09-21
3
473 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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

726 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