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
165
UltraGrid.Rows null
posted

We have a grid listening to update messages that come in real time. If the primary key in message is found in grid, the existing row will be updated. The searching code looks like:

            UltraGridRow targetRow = null;
            this.DataTable.DefaultView.Sort = "key";
            int targetRowViewIndex = this.DataTable.DefaultView.Find(key);
            if (targetRowViewIndex != -1) {
                try
                {
                    targetRow = _grid.Rows.GetRowWithListIndex(targetRowViewIndex);
                }

If not found a new row will be inserted.

During testing i notice the datatable sometimes contains less rows than it should do(e.g. datatable has 1200 rows while the grid has 1400). Sometimes _grid.Rows is null which throws exceptions. These two cases caused existing row not found.

Any thoughts? it is very hard to reproduce. i left the grid open overnight and was able to debug this morning.

 

Thanks,

Xiaojun