Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
235
Key not found
posted

Hi -

I am getting the following error

Key not found
Parameter name: key
System.ArgumentException: Key not found
Parameter name: key
  at Infragistics.Shared.

KeyedSubObjectsCollectionBase.GetItem(String key)
  at Infragistics.Win.UltraWinListView.UltraListViewSubItemColumnsCollection.get_Item(String key)
  at Infragistics.Win.UltraWinListView.UltraListViewSubItemsCollection.get_Item(String key)
  at FtpConnect.MainForm.ResetLastDownloadText()

ResetLastDownloadText functions is as follows --

public void ResetLastDownloadText()
{

               LastDownloadView.Items.Clear();  // this is the WinListView
                DataTable dt = GetDisplayTable();
                int count = 0;
                foreach (DataRow row in dt.Rows)
                {
                    String location = row["Location_Name"].ToString();
                    string downloaded = row["Number_Files_Downloaded"].ToString();
                    String key = count.ToString();
                    count++;
                    Infragistics.Win.UltraWinListView.UltraListViewItem item = LastDownloadView.Items.Add(key, location);
                    item.SubItems["LastDownloadTime"].Value = row["Time"].ToString();
                    item.SubItems["NumberFilesDownloaded"].Value = downloaded;

                }

}

I am not able to reproduce the error in dev. but I assume it is in the highlighted rows (since they are the ones doing the lookups by column names). However, both the columns LastDownloadTime and NumberFilesDownloaded are created at design time and hence are guaranteed to be present. Also, if one of the columns was not present, this error should come up on every run (but that's not the case).

Will appreciate any suggestions.

Sameer

  • 69832
    Suggested Answer
    Offline posted

    I can't even begin to speculate about why this problem is intermittent, but the exception is thrown when you access a member the collection with a non-existent key. If you are able, attach a simple sample project and we will take a look and try to determine why the excception is thrown.