473,395 Members | 1,679 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,395 software developers and data experts.

Data Grid Sort Problem

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

Apr 9 '06 #1
1 1380
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" <al************@btinternet.com> wrote in
message news:11*********************@j33g2000cwa.googlegro 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

Apr 10 '06 #2

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

Similar topics

1
by: Amy Snyder | last post by:
I have a page that has 13 filters used to query a database. I am using the data grid to return the search results. The user has the ability to show from 2-13 columns of data. I have this part...
5
by: pmud | last post by:
Hi, I need to display columns in a data grid based on 7 different queries. Now I have 32 questions: 1. Is it possble to have 1 single data adapter with 7 queries & 1 data set or do I need to...
12
by: pmud | last post by:
Hi, I am using teh following code for sorting the data grid but it doesnt work. I have set the auto generate columns to false. & set the sort expression for each field as the anme of that...
1
by: Da-Breegster | last post by:
Hi. I'm attempting to write a roguelike (think nethack, crawl, angband, tome, adom, and yes, I suppose even rogue) in Perl and I've ran into a problem regarding the data structure for the map and...
1
by: Matthew Louden | last post by:
I am trying to implement the sort event in data grid. I set the data grid's AllowSorting property = True. I implement the following code that should be the event will fire when the user click any...
0
by: Amy Snyder | last post by:
I have a page that has 13 filters used to query a database. I am using the data grid to return the search results. The user has the ability to show from 2-13 columns of data. I have this part...
1
by: Linda | last post by:
Hi, I'm new to asp.net and tryign to learn how to work with data grids. I'm retrieving data from a stored procedure and putting it in a data grid. I then want to be able to sort the data when...
5
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go...
1
by: Bill Sexton | last post by:
I have created a custom DataSourceControl to interface to a search engine. The DataSourceControl exposes multiple views of the same data. The first is the actual search results. The other views...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.