[C#] Index was outside the bounds of the array

  • Thread starter Bj?rn Scheepers via .NET 247
  • Start date
B

Bj?rn Scheepers via .NET 247

I'm struggling with this error for a while now.
First I'll give a shot description of what I'm doing.

I got 2 DataGrids on a webform.
1 with existing task for 1 day, and 1 that gets filled in by using a method FindFreeHours.
It's in that FindFreeHours method that i get a IndexOutOfRangeException.

FindFreeHours() searches for gaps in the task list of that day.
When it gets called for the second time, i get the error at aantal = 0 (aantal = number of).
When i comment the "aantal = 0" the error just moves to the next line.

Some code:

public void FindFreeHours()
{
DataRow dr1;
DataRow dr2;
aantal = 0;
...
}

The BindGrid() method that get's called every time befor the FindFreeHours
private void BindGrid()
{
dsCodfus = cfs.getCfData("5",huidigeDatum.ToShortDateString());
Application["dsCodfus"] = dsCodfus;
grid1.DataSource = dsCodfus.Tables[0].DefaultView;
grid1.DataBind();
}

This code comes from the Page_Load() method. It isn't in the !ispostback part because every action on the form needs an update of the dataset (a webmethod returns the tasks of @user, for @date).

I realy hope somebody could help me out here
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top