473,395 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Reading first Item from asp.net ListBox

I have the following problem:

If I run this code:

dagCap1.berekenDagCapaciteit(ref lbOrderDag1);

I get the error that I can't read the first row from the ListBox.

System.IndexOutOfRangeException: There is no row at position 0

this is the function I use:

public void berekenDagCapaciteit(ref ListBox lbDag)
{
double tempOrderTime = 0.0d;
for (int i = 0; i < lbDag.Items.Count; i++)
{
string orderNr = Convert.ToString(lbDag.Items[i]);
uitvoerenQuery(orderNr);
tempOrderTime = (aantal * runTime) + setupTime;

totaalOrderTime += tempOrderTime;
totaalFreeTime = dagCap - totaalOrderTime;

}
}

When I try to acces the first row when I don't use the for loop for
example like this: r = Convert.ToString(lbDag.Items[0]); The first
item does have a value. I can't find out what's wrong. Has it
something to do with the loop?

Who can help me out,

Robert Smit
Nov 16 '05 #1
2 2574
*When* you do this also matters. Make sure its after all items have been added before you do this operation. Do a check (this.ListBox1.Items.Count must be greater than 0)
Nov 16 '05 #2
*When* you do this also matters. Make sure its after all items have been added before you do this operation. Do a check (this.ListBox1.Items.Count must be greater than 0)
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Peter Bailey | last post by:
I have a function courtesy of the newsgroup that clears the list box. I would like to now set the listbox back to its initial state where you can see the first item in the list. The same goes for a...
1
by: Robert Smit | last post by:
I have the following problem: If I run this code: dagCap1.berekenDagCapaciteit(ref lbOrderDag1); I get the error that I can't read the first row from the ListBox. ...
6
by: orahm | last post by:
I added an object to a listbox. This object is a complex number and not a string so it shows "Consolapplication.Complex" as a list item. If I convert the complex number to a string then it shows a...
1
by: Karen Grube | last post by:
Hi! I'm using a standard server side ASP.Net listbox control on a web form. The page is basically various shades of green. The listbox itself has a pale green background and forest green text...
1
by: Zyrthofar Blackcloak | last post by:
Hi everyone I have a listbox with more items in it than is printed on screen. I need the index number of the first shown item to move another listbox to the same position... Explained differently,...
3
by: Kevin Walzer | last post by:
I'm trying to set the active item in a Tkinter listbox to my application's currently-defined default font. Here's how I get the fonts loaded into the listbox: ...
0
by: scartin | last post by:
Hi, I have a multi-select ListBox that shows 5 rows at a time, but contains possibly a hundred or more items. As I retrieve relevant data from the database, I set the SelectedIndex of the rows...
3
by: perrycheung221 | last post by:
Hi guys, I got 2 listboxes in a window form, one on left and one on right. The 1st listbox have some items while the 2nd listbox is empty. Also there are 2 buttons between the 2 listboxes which...
3
by: peter.mosley | last post by:
I've tried googling for the answer to this problem, without any luck. I'm sure the truth must be out there somewhere! I have a multiselect listbox populated with many items (set by the RowSource...
6
by: Pippen | last post by:
Hi, I'm trying to read all the selected items in a ListBox. So after the user selects the values they want in the ListBox they select a button. This is where I want to put into a string all the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.