Last post Mar 08, 2010 12:51 AM by decker dong - msft
Mar 05, 2010 10:00 AM|supradip_d|LINK
I have a datatable which contains the summery row as well. I just assign the datasource property of a gridview and call databind method to fill and display the records.
Now, when I applied sorting through dataview to the gridview, the sorting happens along with the summery row, which is a normal behavior. As a result the "Total" - column took place inside the data some times. I want to prevent this.
The best way out for that can be done by creating the summery row at grid view row databound. But unfortunately I could not change the datatable as per this requirement.
Please let me know if there is any other way out.
Can the dataview sorting exclude the last row of the datatable through any process?..
Thanks in advance.
Mar 05, 2010 11:08 AM|supradip_d|LINK
For more details I want to know that if there is any process that can sort a particular region of a datatable, so that a couple of rows can be excluded from the sort.
Mar 05, 2010 11:31 AM|hassanmehmood|LINK
That is why "DataView" has "RowFilter".
You can always apply RowFilter on DataView, to exclude the rows from it. Doing so would make you grid to show only the rows without the summary row.
like you can do this (for example)
// do sorting
DataTable.DefaultView.Sort = "ID";
// apply row filter
DataTable.DefaultView.RowFilter = "ID = 14092"
Now this DataView has all rows sorted excluding the row with ID = 14092.
In your case you can assign some identification of Summary Row to the DataView's RowFilter. and your problem will be solved.
Read more about it here
Mark as answer, if it answers you..
Mar 08, 2010 12:51 AM|Decker Dong - MSFT|LINK
Well, I'm unclear about what you say: Is the summary executed in each row in the column called Total?
If you are getting the total number for a certain column for a datatable bound to the GridView, you can just show it in the footer. If you want to avoid Total column from being sorted. You'll have to exclude the column.