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

DataTable modification doubt

Hey, I have a DataTable with few rows pouplated. On some condition, I want the grid to display only the last few rows of the dataTable and few new rows to be added to the end of the last few rows. How do I bring to effect this modification of the DataTable. Thanks..

2 Replies

AD Administrator Syncfusion Team February 10, 2004 02:41 AM UTC

Me again... Just more insight into the doubt - >I have a DataTable with few rows pouplated. On some condition, I want the grid to have only the last few rows of the dataTable and few new rows to be added to the end of the last few rows. Meaning the first few rows of the datatable should be cleared. How do I bring to effect this modification of the DataTable. > >Thanks..


AD Administrator Syncfusion Team February 10, 2004 08:15 AM UTC

If you can pick out the rows you want ot see with a RowFilter string, then you can set the DefaultView.RowFilter property on your datatable. Another way to handle this that does not require being able to write a filter, is to handle teh Model.QueryRowHeight event, and if the e.Index is not one of the rows you want to see, then set its size to 0. //subscribe to the event this.gridDataBoundGrid1.Model.QueryRowHeight += new GridRowColSizeEventHandler(grid_QueryRowHeight); //the handler (showing last 5 rows) private void grid_QueryRowHeight(object sender, GridRowColSizeEventArgs e) { if(e.Index > 0 && e.Index < this.gridDataBoundGrid1.Model.RowCount - 5) { e.Size = 0; e.Handled = true; } }

Loader.
Up arrow icon