I'm facing a low occurrence null reference exception accessing SellectedCells[] in a high volume WebDataGrid. The code is executed several hundred times a day, but I get 3-4 exceptions a week and I cannot determine why. I've added some explicit null checks to isolate what object is null and that only adds to the confusion. The WebDataGrid is bound to a basic DataSet and it is not possible for any "cell" in the DataSet to be empty much less null. I'm getting null reference exceptions on x=0 and x=1/2/6/etc. I cannot force duplicate this no matter how much I try so I have the following code added to trap/log occurrences as they happen in the production environment.
if (WebDataGridWaves.Behaviors.Selection.SelectedCells.Count != 0)
{
for (int x = 0; x < WebDataGridWaves.Behaviors.Selection.SelectedCells.Count; x++)
// Debug data for NullReferenceException accessing WebDataGridWaves
try
if (WebDataGridWaves.Behaviors.Selection.SelectedCells[x] == null)
Common.LogEvent("Error", "DeployConvergenceApplicationBySite", "SelectedCells[x] is null\r\n\r\nSite = " + sSite + "\r\nWebDataGridWaves.Behaviors.Selection.SelectedCells.Count = " + WebDataGridWaves.Behaviors.Selection.SelectedCells.Count.ToString() + "\r\nx = " + x.ToString());
}
else
if (String.IsNullOrEmpty(WebDataGridWaves.Behaviors.Selection.SelectedCells[x].Text))
Common.LogEvent("Error", "DeployConvergenceApplicationBySite", "SelectedCells[x].Text is NullOrEmpty\r\n\r\nSite = " + sSite + "\r\nWebDataGridWaves.Behaviors.Selection.SelectedCells.Count = " + WebDataGridWaves.Behaviors.Selection.SelectedCells.Count.ToString() + "\r\nx = " + x.ToString());
string sTemp = WebDataGridWaves.Behaviors.Selection.SelectedCells[x].Text;
catch (Exception ex)
Common.LogEvent("Error", "DeployConvergenceApplicationBySite", "Message:\r\n" + ex.Message + "\r\nStackTrace:\r\n" + ex.StackTrace + "\r\n\r\nSite = " + sSite + "\r\nWebDataGridWaves.Behaviors.Selection.SelectedCells.Count = " + WebDataGridWaves.Behaviors.Selection.SelectedCells.Count.ToString() + "\r\nx = " + x.ToString());
Here are some of the examples being logged:
Exception in DeployConvergenceApplicationBySite
SelectedCells[x] is null
Site = CTI_pl_bhw
WebDataGridWaves.Behaviors.Selection.SelectedCells.Count = 11
x = 6
Site = MEX
WebDataGridWaves.Behaviors.Selection.SelectedCells.Count = 10
x = 2
Site = KR
WebDataGridWaves.Behaviors.Selection.SelectedCells.Count = 4
x = 0
Any suggestions on why a SellectedCell[x] would be null when Count > x ?
Hello,
Thank you for contacting Infragistics!
I have done some looking into this matter and have some follow up questions concerning this matter:
What version of the Infragistics controls are you using?
How are you setting up the grid?
How are you setting up the selection behavior?
The code you use to look at the selected cells where is this being run?
I am following up to see if you can provide me with answers to my questions.
Please let me know if I may be of further assistance with this matter.