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

Dropdown displaying data in the wrong order

Hello Everyone,

I am populating a dropdown control from a database where the data is
datetime values. In my stored procedure I am ordering them by where the most
recent is at the top and the earliest is the last. So the following is
displayed in SQL Query Analyzer

7/28/2004
7/1/2004
6/302004

The above order is correct and that is the way I expect them to be displayed
in the drop down. However in the drop down they get displayed as follow(s):

7/28/2004
6/302004
7/1/2004

I am not exactly sure why it is being displayed like this, because when I
step through the code I can see it been put in the correct order, so I was
wondering if anyone had any ideas on this.

The code that is doing this is as follow(s):
ResetParameters()

..AddParameter("iMRN", OleDb.OleDbType.Integer, ParameterDirection.Input,
ctlHeader.PatientData("PatientMRN"))

'Pull back the list of encounters for the selected patient

If .Execute(.genuSql.StoreProcSelect, "selPatient_Billing") Then

Dim oRow As DataRow

oData = .DbData_DataTable

If .DbData_DataTable.Rows.Count > 0 Then

With drpEnc

..DataSource = oData

..DataBind()

..DataValueField = "id"

..DataTextField = "DateOfService"

End With

End If

Else

Throw New Exception(.ErrorMessage)

End If 'Encounter List
Any help would be appreciated.

JD
Nov 18 '05 #1
2 1682
Does the Stored Procedure have an "order by" clause in it? If you don't
specify an "order by" clause in SQL Server, then the result set is not
guaranteed to have any specific order.

The other option would be to take your resultset and put it into a DataView
and sort with the DataView.

--
Ben Lucas
Lead Developer
Solien Technology, Inc.
www.solien.com

"Irishmaninusa"
<jd***@structuctureinteractive.com.takemeoffifyouw antoemailme> wrote in
message news:uz*************@TK2MSFTNGP11.phx.gbl...
Hello Everyone,

I am populating a dropdown control from a database where the data is
datetime values. In my stored procedure I am ordering them by where the most recent is at the top and the earliest is the last. So the following is
displayed in SQL Query Analyzer

7/28/2004
7/1/2004
6/302004

The above order is correct and that is the way I expect them to be displayed in the drop down. However in the drop down they get displayed as follow(s):
7/28/2004
6/302004
7/1/2004

I am not exactly sure why it is being displayed like this, because when I
step through the code I can see it been put in the correct order, so I was
wondering if anyone had any ideas on this.

The code that is doing this is as follow(s):
ResetParameters()

.AddParameter("iMRN", OleDb.OleDbType.Integer, ParameterDirection.Input,
ctlHeader.PatientData("PatientMRN"))

'Pull back the list of encounters for the selected patient

If .Execute(.genuSql.StoreProcSelect, "selPatient_Billing") Then

Dim oRow As DataRow

oData = .DbData_DataTable

If .DbData_DataTable.Rows.Count > 0 Then

With drpEnc

.DataSource = oData

.DataBind()

.DataValueField = "id"

.DataTextField = "DateOfService"

End With

End If

Else

Throw New Exception(.ErrorMessage)

End If 'Encounter List
Any help would be appreciated.

JD

Nov 18 '05 #2
yes, the stored procedure has a order clause in it (thought I had mentioned
that down below, sorry if I hadn't made it clear enough).

I will take a look at the dataview, but I am not sure if that will work for
this situation.

"Ben Lucas" <be*@nospam.solien.nospam.com> wrote in message
news:GP********************@comcast.com...
Does the Stored Procedure have an "order by" clause in it? If you don't
specify an "order by" clause in SQL Server, then the result set is not
guaranteed to have any specific order.

The other option would be to take your resultset and put it into a DataView and sort with the DataView.

--
Ben Lucas
Lead Developer
Solien Technology, Inc.
www.solien.com

"Irishmaninusa"
<jd***@structuctureinteractive.com.takemeoffifyouw antoemailme> wrote in
message news:uz*************@TK2MSFTNGP11.phx.gbl...
Hello Everyone,

I am populating a dropdown control from a database where the data is
datetime values. In my stored procedure I am ordering them by where the

most
recent is at the top and the earliest is the last. So the following is
displayed in SQL Query Analyzer

7/28/2004
7/1/2004
6/302004

The above order is correct and that is the way I expect them to be

displayed
in the drop down. However in the drop down they get displayed as

follow(s):

7/28/2004
6/302004
7/1/2004

I am not exactly sure why it is being displayed like this, because when I step through the code I can see it been put in the correct order, so I was wondering if anyone had any ideas on this.

The code that is doing this is as follow(s):
ResetParameters()

.AddParameter("iMRN", OleDb.OleDbType.Integer, ParameterDirection.Input,
ctlHeader.PatientData("PatientMRN"))

'Pull back the list of encounters for the selected patient

If .Execute(.genuSql.StoreProcSelect, "selPatient_Billing") Then

Dim oRow As DataRow

oData = .DbData_DataTable

If .DbData_DataTable.Rows.Count > 0 Then

With drpEnc

.DataSource = oData

.DataBind()

.DataValueField = "id"

.DataTextField = "DateOfService"

End With

End If

Else

Throw New Exception(.ErrorMessage)

End If 'Encounter List
Any help would be appreciated.

JD


Nov 18 '05 #3

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

Similar topics

8
by: Kris Rockwell | last post by:
Hello, I have done the following to bind data to a DropDown box: 1. Drag SQLServer table onto web form to create data connection and data adapter. 2. Generate dataset by right-clicking on...
4
by: MrL8Knight | last post by:
Hello, I am trying to build a simple php form based shopping cart using a cookie with arrays. I need to use 1 cookie because each order will have over 20 items. With that said, I realize I need to...
4
by: Dabbler | last post by:
I have two tables I'm editing in a Gridview. The VANS table contains a key to the other LESSOR table. I would like to use a dropdown list to select the LessorId value while displaying the Lessor...
1
by: William Youngman | last post by:
I have a gridview displaying data and would like to use the AJAX dropdown extender so that when the user clicks on a record a dropdown menu will display providing the user with a menu of selections...
13
by: Shutey | last post by:
I have a strange issue with dropdowns. Using php4, mySQL5, Apache 2 on a fast XP pro PC, I have a form which requires 5 dropdowns populated with indentical values. I extract the values using SQL...
4
by: Panna | last post by:
Hey there I am using phpMyAdmin and MySQL to develop a dbase application. I have a dropdown menu on one of the pages which gets populated automatically with data from a table in the database....
7
by: fran7 | last post by:
Hi, I am having trouble with this dropdown. With it I am passing an id to the next page but displaying a description in the dropdown. Trouble is it displays a description for every postid so I am...
2
coolv
by: coolv | last post by:
Hello I have problem in my page that the dropdown box is not displaying data according to selection of first dropdown.Please help me. Below is my code. thanks.............. <?php ...
2
by: pavanip | last post by:
Hi, I have a problem with binding data to dropdownlist from database in alphabetical order. My database contains some fields like All,Air,Airline,Books,Cars etc. There are 2 dropdown...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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
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...

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.