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

Grid Binding

Hi I am filling a grid by looping through the Datatable and inserting a new row in the grid.Thr grid adds rows equaivalent to the number of rows in the Datatable . 2. Second thing i do on the grid is I add the headers in between the grid rows. Lets say I have 50 rows . based on some field in the datatable which gets changed I insert a new row in the grid of type Header . Which actually displays that the rows below the grid belongs to some particular category.I hope i Am clear till this point. 3. There is a column in the Datatable Say GOAL and the same column is there in the grid. Now I change the values in the GOAL Column of the grid. On the Grids Editing Complete I update the datatable and uses some private functions on the datatable to calculate the values which actually affected other rows GOAL columns.Functions work well but the Grid is not Updated Actually.Clear till this point !! 4. So to update the Grid I loop through the datatable and based on a primary field in the Datatable I search the record in the grid again looping through the grid and When i find the matched value I update the GOAL value in the grid.but this is so time consuming it takes around 2 minutes. I want to know can i bind the grid GOAL column to the Datatable Column after the screen is loaded so that my grid values should be updated automatically as soon as I am changing the values in the grid Keepng in mind that I have some rows in the Grid which are headers only and are of display porpose.

2 Replies

AD Administrator Syncfusion Team June 6, 2005 11:35 AM UTC

You did not say what kind of grid you were using, so I assume it is a GridControl. One possible way to speed things up is that after the grid has be populated the way you want it, you loop through the grid one time, creating a hashtable whose keys are the primary-key value for the row in the grid and whose value is the rowindex of the row in the grid. (ie, create a hashtable that maps primary key values to grid row indexes.) Then in step 3, when you call you private functions to change particular values directly in your datatable, you can use this hashtable to look up the proper row that you need to update, and not have to search for it.


LL Lokesh Luthra June 6, 2005 02:06 PM UTC

Hi Clay HATS OFF ...Time has drastically reduced to 4 seconds from 2 minutes .Thanx n Cheers >You did not say what kind of grid you were using, so I assume it is a GridControl. > >One possible way to speed things up is that after the grid has be populated the way you want it, you loop through the grid one time, creating a hashtable whose keys are the primary-key value for the row in the grid and whose value is the rowindex of the row in the grid. (ie, create a hashtable that maps primary key values to grid row indexes.) Then in step 3, when you call you private functions to change particular values directly in your datatable, you can use this hashtable to look up the proper row that you need to update, and not have to search for it.

Loader.
Live Chat Icon For mobile
Up arrow icon