Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / April 2006

Tip: Looking for answers? Try searching our database.

DataGrid Sort Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
thebison - 10 Apr 2006 00:08 GMT
Hi all,

I hope someone can help with this relatively simple problem.
I am building a timesheet application using ASP.NET C# with Visual
Studio 2003.As it is only a protoype application, my database has been
made in MSDE.

I've searched all over the web for the answer to this, but can't quite
work it
out. Basically, I am showing all Timesheet Entries in a DataGrid, by
applying a DataView to a DataSet. This works fine, and now I need to
sort the entries. I want my sort order to be done by ResourceID, Day.
The problem is that my Database has the days of the week stored as a
string (i.e. each entry will be for one of of the following
'Mon','Tues','Weds', 'Thurs', 'Fri', 'Sat', 'Sun')

The problem when sorting is that if I sort by 'Day', because it's a
string it will do it alphabetically. Obviously this is wrong,  I want
it to sort it in the order of the days of the week as shown above. How
would I go about achieving this? I thought about assigning values to
each day when adding to the database (this is done by a drop-down list
so Monday could =1, Tuesday =2, Weds = 3 etc). However when I then pull
the data into the DataGrid, it will be stored as numbers, not Days.

Does anyone have any suggestions as to how I could solve this? To
re-iterate, I have a column called 'Day' which will contains one of the
7 days of the week, and I wish to sort rows in 'Day' logical order.

Thanks in advance

Al
OHM ( One Handed Man ) - 10 Apr 2006 06:04 GMT
One way would be to add a hidden column with the numbers representing the
days, when you sort, sort on this column not the string representing the
day.

Signature

( OHM ) - One Handed Man
AKA Terry Burns - http://TrainingOn.net

> Hi all,
>
[quoted text clipped - 27 lines]
>
> Al
Cor Ligthert [MVP] - 10 Apr 2006 07:16 GMT
The Bison,

In addition of OHM answers here a link to our website where is showed how
easy it is to do that.

http://www.vb-tips.com/default.aspx?ID=76a81eb8-ea2d-48f4-99c3-a3539697edbd

I hope this helps,

Cor

> Hi all,
>
[quoted text clipped - 27 lines]
>
> Al

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.