Solved

Index out of range

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Name space syntax error 12 57
Entity Framework 7 42
Need help with setting the location of a Navigate.URL for an asp.net web form. 4 26
IIS redirect 1 68
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

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