M
MR
I am getting the exception "There is no row at position 5" on a dataview
that has 10 rows (count = 10)
The original dataset, i.e. unfiltered, has 12 rows. when it is filtered,
there are 10. i can look in the dataview and see all ten rows. but when i am
in the foreach(DataRowViw pr in orderDV) loop i get the error when i try to
access a field in the sixth row (position 5).
i cannot figure out why i keep getting this exception . does anyone know
why?
thanks
m
I have included the code that causes this error:
string Filter = "BatchID = " + BatchID.ToString(); // usullay BatchID = 0
DS.Tables[OrderTable].DefaultView.RowFilter = Filter;
DataView orderDV = DS.Tables[OrderTable].DefaultView;
foreach(DataRowView pr in orderDV)
{
string Orders_Id = pr["OrderNumber"].ToString(); // why do i get an
exception here?
//pr["OrderNumber"]
{"There is no row at position 5." } System.IndexOutOfRangeException
foreach (DataRow cr in pr.Row.GetChildRows("OrderCollection"))
{
}
pr["BatchID"] = 1; // assign new BatchID
}
that has 10 rows (count = 10)
The original dataset, i.e. unfiltered, has 12 rows. when it is filtered,
there are 10. i can look in the dataview and see all ten rows. but when i am
in the foreach(DataRowViw pr in orderDV) loop i get the error when i try to
access a field in the sixth row (position 5).
i cannot figure out why i keep getting this exception . does anyone know
why?
thanks
m
I have included the code that causes this error:
string Filter = "BatchID = " + BatchID.ToString(); // usullay BatchID = 0
DS.Tables[OrderTable].DefaultView.RowFilter = Filter;
DataView orderDV = DS.Tables[OrderTable].DefaultView;
foreach(DataRowView pr in orderDV)
{
string Orders_Id = pr["OrderNumber"].ToString(); // why do i get an
exception here?
//pr["OrderNumber"]
{"There is no row at position 5." } System.IndexOutOfRangeException
foreach (DataRow cr in pr.Row.GetChildRows("OrderCollection"))
{
}
pr["BatchID"] = 1; // assign new BatchID
}