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.
Please mark this reply as answer if it helps you to solve the problem mentioned.
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.
Thanks again..
Please mark this reply as answer if it helps you to solve the problem mentioned.
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.
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.
supradip_d
Member
260 Points
76 Posts
Exclude a row from Dataview Sort
Mar 05, 2010 10:00 AM|LINK
Hi,
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.
Thank you & Regards,
Supradip Dey
supradip_d
Member
260 Points
76 Posts
Re: Exclude a row from Dataview Sort
Mar 05, 2010 11:08 AM|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.
Thanks again..
Thank you & Regards,
Supradip Dey
hassanmehmoo...
Star
8970 Points
1590 Posts
Re: Exclude a row from Dataview Sort
Mar 05, 2010 11:31 AM|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
http://msdn.microsoft.com/en-us/library/system.data.dataview.rowfilter.aspx
--
Mark as answer, if it answers you..
--
Mark as Answer, if it answers you..
--
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Exclude a row from Dataview Sort
Mar 08, 2010 12:51 AM|LINK
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.
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.