Solved

Index out of range

Posted on 2004-09-21
3
463 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
3 Comments
 
LVL 3

Expert Comment

by:w_shaila
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
deploying a service to production environment 13 81
popup message 3 26
Whats wrong with this query 21 39
JavaScript error 1 33
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
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 …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now