List<dc.zlkEquipmentAttributeName> q = _equipment.Getzlk(val);
inflv.UltraListViewItem[] items = new Infragistics.Win.UltraWinListView.UltraListViewItem[q.Count]; Infragistics.Win.UltraWinListView.UltraListViewItem ulv;
for (int i =0; i < q.Count; i++) { //ulv = new Infragistics.Win.UltraWinListView.UltraListViewItem(q[i].description); //ulv = new Infragistics.Win.UltraWinListView.UltraListViewItem(q[i].attributeNameID.ToString());
ulv = new Infragistics.Win.UltraWinListView.UltraListViewItem(); ulv.Key = q[i].attributeNameID.ToString(); ulv.Value = q[i].description; items[i] = ulv;
}
lstEquipment.Items.AddRange(items);
I get Object reference not set to an instance of an object. items is obviously set so I guess I am setting up the individual items incorrectly. Can someone give me an example of what I should be doing.
lstQuery.Items.Add(_bq.Id.ToString(),
,
, cmbType.Text.ToString(), ultraEnum.Current.Value.ToString()));
I was not casting the key to a string.
If you are running in debug mode, and a null reference exception is thrown, execution will halt right on the offending line of code. You need to examine that line of code to determine what object is null. You are not setting up the items incorrectly.
The id is not null. I even looped through each one just to be sure.
System.Console.WriteLine("Key: " + i.Key + " Value: " + i.Value);
Returns
Key: 1 Value: Air Compressor
Can you give me an example of how to do this?
One possibility is that the 'attributeNameID' member of an element in the 'q' list is null; you are calling ToString on it without checking, so if it is null you would get a null reference exception.
Infragistics.Win.UltraWinListView.UltraListViewItem ultraListViewItem11 = new Infragistics.Win.UltraWinListView.UltraListViewItem("joe", null, null); Infragistics.Win.UltraWinListView.UltraListViewItem ultraListViewItem12 = new Infragistics.Win.UltraWinListView.UltraListViewItem("kenny", null, null); Infragistics.Win.UltraWinListView.UltraListViewItem ultraListViewItem13 = new Infragistics.Win.UltraWinListView.UltraListViewItem("erin", null, null);
ultraListViewItem11.Key = "11"; ultraListViewItem12.Key = "12"; ultraListViewItem13.Key = "13"; this.lstEquipment.Items.AddRange(new Infragistics.Win.UltraWinListView.UltraListViewItem[] { ultraListViewItem11, ultraListViewItem12, ultraListViewItem13});
Also fails