We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridDataBoundGrid Sorted Refresh Problem

Thread ID:





18250 Aug 26,2004 02:11 PM UTC Aug 26,2004 06:28 PM UTC WinForms 7
Tags: GridControl
Administrator [Syncfusion]
Asked On August 26, 2004 02:11 PM UTC

I am having a problem with the databoundgrid. When I attempt to do a refresh (i.e. clear the underlying data in the datatable and then reload it) when one of the rows are sorted in the grid, the last row in the grid gets duplicated. Are there any fixes or work arounds to this? I am using

Administrator [Syncfusion]
Replied On August 26, 2004 02:17 PM UTC

Here is some code that might be overkill, but would probably work. grid.BeginUpdate(); grid.DataSource = null; //clear you DataTable and reload it... grid.DataSource = myDataTable; grid.EndUpdate(); grid.Refresh();

Administrator [Syncfusion]
Replied On August 26, 2004 02:23 PM UTC

Thanks, that works. One more thing, is there a way to disable the sort durring the refresh and then re-enable it after the refresh. It seems to take much longer to load up the data, if sorting is turned on.

Administrator [Syncfusion]
Replied On August 26, 2004 02:31 PM UTC

This probably has nothing to do with the grid as the grid should be disconnected from the datasource at this point. You could try saving dataTable1.DefaultView.Sort to a string, then set dataTable1.DefaultView.Sort = "", and then clearing your datatable, followed by resetting the saved value to see if that sppeds things up.

Administrator [Syncfusion]
Replied On August 26, 2004 03:04 PM UTC

OK, the refresh is working now. However, I have another problem. In the Grid, I am using a GridFilterBar. I realized that I had to re-add the filter bar everytime I do a refresh. However, it seems to first draw the entire grid w/o the filter bar, and then re-draws it w/ the filter bar. This causes the grid to look jumpy on refresh. Is there a way to get around this. Michael Sabin

Administrator [Syncfusion]
Replied On August 26, 2004 04:46 PM UTC

Normally, you can turn off grid drawing by calling grid.BeginUpdate(). Then later you can turn it back on by calling grid.EndUpdate. You may have to also then call grid.Refresh to repaint things.

Administrator [Syncfusion]
Replied On August 26, 2004 05:42 PM UTC

I was able to stop this behavior if I first unwire the grid before the refresh, and re-wire it after loading the data. However, I still see the behavior if I am sorting on one of the columns. Oddly enough, I am using the form in an MDI tab pane, and if I switch to another form, the behavior goes away until is modify the sort again. Here is a code snippet of my refresh method: Refresh () { // save selected items GridRangeInfoList rangeList = new GridRangeInfoList(); grid.Selections.GetSelectedRanges(out rangeList, false); grid.Selections.Clear(); grid.BeginUpdate(); gridFilter.UnwireGrid(); grid.DataSource = null; datatable.Clear(); LoadData(datatable); grid.DataSource = datatable; gridFilter.WireGrid(grid, gridStyle); grid.EndUpdate(); grid.Refresh(); // restore the selected items foreach (GridRangeInfo rangeInfo in rangeList) grid.Selections.Add(rangeInfo); }

Administrator [Syncfusion]
Replied On August 26, 2004 06:28 PM UTC

You are correct. If you are clearing your datatable, then I think you will have to unwire and then rewire the grid.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon