Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Data Grid Sort Problem

Reply
Thread Tools

Data Grid Sort Problem

 
 
thebison
Guest
Posts: n/a
 
      04-09-2006
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

 
Reply With Quote
 
 
 
 
OHM \( One Handed Man \)
Guest
Posts: n/a
 
      04-10-2006
Do you also have a date associated with the day, if so use this to sort on,
else you could add an additional column to the bound DataTable which stored
an integer representing the day, hide this in the datagrid, but use it to
sort on.

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

"thebison" <> wrote in
message news: ups.com...
> 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chris Pine tutorial assistance chapter 7 sort data without use of.sort method jgheal@googlemail.com Ruby 9 11-27-2008 07:36 PM
Sort Event does not fire when EnableViewState =false for data grid =?Utf-8?B?VmlkZHM=?= ASP .Net 1 10-09-2007 12:15 PM
sort image or style on data grid Brian Henry ASP .Net 4 07-15-2004 03:32 AM
Sort Dynamic Data Grid Amy Snyder ASP .Net 0 12-02-2003 03:01 PM
Ado sort error-Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. Navin ASP General 1 09-09-2003 07:16 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57