By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,287 Members | 1,524 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,287 IT Pros & Developers. It's quick & easy.

Datagridview - sort string column numerically

P: n/a
Hi all,

I have a "connected" datagridview that uses a bindingsource/datatable to
load the grid and update the user's modifications to the database. I have a
column that is set in the database as varchar, but it is populated with
values ranging from 1 to 49. It is not an option to change the column to
integer in the database.

When I sort the column by clicking on the column header it sorts
alphabetically as expected (Ex. 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2,
20, 21, etc...). I would like to figure out a way to make it appear that it
is sorting numerically (Ex. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, etc...).

One work around I found was to convert the column to an integer column
during the sql that I retrieve the data with. This resolves the issue when I
click on a column header - the values sort numerically. However, when I
update the user's modifications to the database this column value does not
update. It does not error. It just leaves the original value in the
database. I use datatable.Update for committing the user's changes to the
database. Thus, converting on the way in is not an option.

Any suggestions would be GREATLY appreciated!

Thanks in advance for any assistance! Have a great day!
Oct 2 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.