Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Index out of range

Posted on 2004-09-21
3
Medium Priority
?
479 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

610 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