I am getting an exception
System.ArgumentOutOfRangeException: There is no row at position 1. RBTree`1.GetNodeByIndex(Int32 userIndex)**
There is no row at position can be 0 or 1 or 2 . I guess i am trying to read or write some array elements which are outside of your array boundary. The code snippet is shown below
public void ManageAlarm(string textName, int leaveValue)
{
try
{
int indices = team.Find(textName);
if (indices >= 0)
{
DataRow row = teamTable.Rows[indices];
row[m_leaveValues] = leaveValue;
}
}
What should i do here to prevent this alert trace
You need to check the rows count in m_tblAlert before you access rows in it. m_tblAlert.Rows.Count must be greater then indx
public void ManageDuplicateAlarm(string alertName, int dupValue)
{
try
{
int indx = m_alerts.Find(alertName);
if (indx >= 0 && m_tblAlert.Rows.Count > indx)
{
DataRow row = m_tblAlert.Rows[idx];
m_dcDuplicates.ReadOnly = false;
row[m_dcDuplicates] = dupValue;
m_dcDuplicates.ReadOnly = true;
}
}
Edit more exlanation on OP comment
You are checking indx >= 0 to make sure that that -1 could not be row index
for statement m_tblAlert.Rows[idx]; Similarly you need to check if the value return by m_alerts.Find(alertName) must be valid row number ie it should not be greater then the number of rows
you have in data table.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.