Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Dropdown displaying data in the wrong order

Reply
Thread Tools

Dropdown displaying data in the wrong order

 
 
Irishmaninusa
Guest
Posts: n/a
 
      08-26-2004
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


 
Reply With Quote
 
 
 
 
Ben Lucas
Guest
Posts: n/a
 
      08-26-2004
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"
<(E-Mail Removed) antoemailme> wrote in
message news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Irishmaninusa
Guest
Posts: n/a
 
      08-27-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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"
> <(E-Mail Removed) antoemailme> wrote in
> message news:(E-Mail Removed)...
> > 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
> >
> >

>
>



 
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
1 Gridview. Dropdown A is column from database, Dropdown B is column from database, Data in A and B must be from same row. anonymoushamster@gmail.com ASP .Net 2 11-07-2007 12:40 PM
ajax cascading dropdown: second dropdown disabled acadam ASP .Net 0 12-27-2006 10:59 AM
bind a dropdown in a column in a datagrid based on the dropdown value selected in another column of the datagrid. vishnu ASP .Net 1 03-25-2006 01:24 PM
Select dropdown box bleeds into Javascript dropdown menu Mike HTML 1 12-18-2003 09:49 PM
Edit Mode - How do I populate dropdown in edittemplate from dropdown in another column? Steve Myers ASP .Net Datagrid Control 2 11-20-2003 01:09 PM



Advertisments