Dropdown displaying data in the wrong order

Discussion in 'ASP .Net' started by Irishmaninusa, Aug 26, 2004.

  1. 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
    Irishmaninusa, Aug 26, 2004
    #1
    1. Advertising

  2. Irishmaninusa

    Ben Lucas Guest

    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"
    <> wrote in
    message news:...
    > 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
    >
    >
    Ben Lucas, Aug 26, 2004
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    > 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"
    > <> wrote in
    > message news:...
    > > 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
    > >
    > >

    >
    >
    Irishmaninusa, Aug 27, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vishnu
    Replies:
    1
    Views:
    1,187
    Patrick.O.Ige
    Mar 25, 2006
  2. Mike
    Replies:
    1
    Views:
    793
  3. acadam
    Replies:
    0
    Views:
    745
    acadam
    Dec 27, 2006
  4. Replies:
    2
    Views:
    430
  5. Steve Myers
    Replies:
    2
    Views:
    264
    Steve Myers
    Nov 20, 2003
Loading...

Share This Page