473,385 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Sorting a Datagridview

Hi

I have a datagridview control which I am binding to a datatable. Before
binding to a datatable I am adding one row in the datatable for Total
and populating data in that row at runtime.

Now when user click the header of the column data gets sorted. I always
want the row which is displaying TOTAL at the end.

I have scenario as mentioned below. Is there a way to keep the total
row always at the end ?
I mean sorting should always be the last row in datagrid.

------------------------------------------------
col1 col2
------------------------------------------------
column1 1000
column2 1500

Total 2500

-----------------------------------------------------------------

May 17 '06 #1
3 2428
You need to manually remove/add you total row before/after sorting, or don't
use the total at all - it that case I suggest to use DataTable.Select to set
the function calculating your total number
I have a datagridview control which I am binding to a datatable. Before
binding to a datatable I am adding one row in the datatable for Total
and populating data in that row at runtime.

Now when user click the header of the column data gets sorted. I always
want the row which is displaying TOTAL at the end.

I have scenario as mentioned below. Is there a way to keep the total
row always at the end ?
I mean sorting should always be the last row in datagrid.


--
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche

May 17 '06 #2
Hi Michael

Thanks for your reply. I think I will go with manually remove/add total
row.

I was just wondering do you have any sample code for that ?

Regards

Amit

May 17 '06 #3
Try to do it by your own way, it's more intriguing :)

"am*******@gmail.com" wrote:
Hi Michael
Thanks for your reply. I think I will go with manually remove/add total
row.
I was just wondering do you have any sample code for that ?
Regards
Amit


--
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche

May 17 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: cc | last post by:
Hi, using the DataGridView (.NET 2005) : I have a row currently selected in the Grid (say the 3rd row showing 'Product3') Now, when I click on a column to sort the records is the 'Product3'...
3
by: Harry Haller | last post by:
Hello, I want to implement a generic list which will be used to display 7 columns in a GridView. One should be able to sort, filter and page each of the 7 columns. Ideally the filter should be...
0
by: mahesh.nimbalkar | last post by:
I want to use Multi column sorting in DataGridView. The scenario is like this: 1) DataGridView has two columns; Id and name 2) User clicks on Id column and DataGridView is sorted...
1
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I'm using a DataGridView on a Form. I want to disable the clicking on the columns headers to disallow the sorting. How can I do that, but without deriving the DataGridView? Is there any other...
8
by: Kyote | last post by:
On my form I have a datagridview that's bound to a table on my DB. When I run the app then click on a column header to sort, it sorts just fine. But my problem is a result of that sort. Even...
1
by: Ahmed Yasser | last post by:
Hi all, i have a problem with the datagridview sorting, the problem is a bit complicated so i hope i can describe in the following steps: 1. i have a datagridview with two columns...
4
by: ReneMarxis | last post by:
Hello i have one problem with sorting in an unbound DataGridView. I set sorting to automatic but i get errors when having DBNull values in the column that gets sort ("Object must be of type...
6
by: stocki | last post by:
Hi, On my WinForm I have a DataGridView, which contains four columns and four rows. The last row contains only a sum of the values of the cells of the previous rows in column 3. The cells , , ...
7
Plater
by: Plater | last post by:
I am having trouble determining when my DataGridView object is sorting (based on a column header click). The idea is, in a large table, sorting the columns takes time, so I show a splash screen....
0
by: Queez | last post by:
OK, this is rediculous... Surely, sorting should be one of the easiest things with the ASP.NET DataGridView control. I mean, there's hundreds of sites out there (Microsoft MSDN entries included)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.