473,791 Members | 3,122 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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, ParameterDirect ion.Input,
ctlHeader.Patie ntData("Patient MRN"))

'Pull back the list of encounters for the selected patient

If .Execute(.genuS ql.StoreProcSel ect, "selPatient_Bil ling") Then

Dim oRow As DataRow

oData = .DbData_DataTab le

If .DbData_DataTab le.Rows.Count > 0 Then

With drpEnc

..DataSource = oData

..DataBind()

..DataValueFiel d = "id"

..DataTextField = "DateOfServ ice"

End With

End If

Else

Throw New Exception(.Erro rMessage)

End If 'Encounter List
Any help would be appreciated.

JD
Nov 18 '05 #1
2 1700
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

"Irishmanin usa"
<jd***@structuc tureinteractive .com.takemeoffi fyouwantoemailm e> wrote in
message news:uz******** *****@TK2MSFTNG P11.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, ParameterDirect ion.Input,
ctlHeader.Patie ntData("Patient MRN"))

'Pull back the list of encounters for the selected patient

If .Execute(.genuS ql.StoreProcSel ect, "selPatient_Bil ling") Then

Dim oRow As DataRow

oData = .DbData_DataTab le

If .DbData_DataTab le.Rows.Count > 0 Then

With drpEnc

.DataSource = oData

.DataBind()

.DataValueField = "id"

.DataTextField = "DateOfServ ice"

End With

End If

Else

Throw New Exception(.Erro rMessage)

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.sol ien.nospam.com> wrote in message
news:GP******** ************@co mcast.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

"Irishmanin usa"
<jd***@structuc tureinteractive .com.takemeoffi fyouwantoemailm e> wrote in
message news:uz******** *****@TK2MSFTNG P11.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, ParameterDirect ion.Input,
ctlHeader.Patie ntData("Patient MRN"))

'Pull back the list of encounters for the selected patient

If .Execute(.genuS ql.StoreProcSel ect, "selPatient_Bil ling") Then

Dim oRow As DataRow

oData = .DbData_DataTab le

If .DbData_DataTab le.Rows.Count > 0 Then

With drpEnc

.DataSource = oData

.DataBind()

.DataValueField = "id"

.DataTextField = "DateOfServ ice"

End With

End If

Else

Throw New Exception(.Erro rMessage)

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
278
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 the data adapter ad selecting generate dataset.
4
7158
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 serialize the data to put the array into the cookie. That part of my code is working just fine and displaying fine. The problem I’m having is when I try to unserialize and display; the data does not appear. If I remove my unserialize command line (see...
4
29540
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 table's "Company" field as text. When I commit the edit I get error:Must declare the scalar variable "@LessorId". Also as a bonus question ;) I don't know how to set the selectedindex value in the dropdown list based on the LessorId value in the...
1
9688
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 to choose from (yes much like the SharePoint 2007 dropdown menu). I'm having problems dynamically binding the 'TargetControlID' property of the extender control to the record label in the gridview. What I'm doing is - The label's text is the...
13
2200
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 and populate 2 variables and use a for-next loop to create the dropdown. The dropdown contains some 310 items! It works beautifully if I have 1 or 2 dropdowns but as soon as I add more it partially creates the 3rd and just stops until it times out!...
4
3431
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. The code for this is as follows: $sql3="SELECT ID, UploadDate FROM Telkom"; $result2=mysql_query($sql3); $options="";
7
1863
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 getting multiple duplicate descriptions in the dropdown. like drawing drawing drawing ceramics ceramics. I can see the problem as I am passing a unique postid its populating the dropdown with all the descriptions associated with my postids. I...
2
2218
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 session_start(); if (!isset($_SESSION)) {
2
4183
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 lists one dropdown contains A to Z list like A,B,C,D..Z. 2nd list contains above items like All,Air,Books.Now I want that when I select A from A-Z list it will display A items in alphabetical order and the Top item should be "All" after that remaining...
0
9512
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10419
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10201
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10147
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9987
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9023
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5552
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3709
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2910
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.