DataView Sort Bug

Discussion in 'ASP .Net' started by Mike Kline, Feb 14, 2005.

  1. Mike Kline

    Mike Kline Guest

    Hi All!

    I've this strange DataView sort bug and i can't do any sorting
    activities! Below is my code...

    ---VB.NET Code---

    dvFinal = New DataView(objDataSet.Tables(CON_FinalTable))

    Dim strSort As String = drpOrderBy.Text & " " & drpOrderStyle.Text
    dvFinal.Sort = strSort

    Response.Write(strSort)

    ---End VB.NET Code---

    And I got the following error...

    ---Error Message---

    Exception Details: System.IndexOutOfRangeException: Cannot find column ASC

    ---End Error Message---

    I don't know why DataView is treating sort expression "ASC" as the
    column name!!!

    Please help!!!

    Thank you all in advance!!!
    MK
    Mike Kline, Feb 14, 2005
    #1
    1. Advertising

  2. Have you eliminated the possibility that drpOrderBy.Text is empty?
    So that what actually gets passed in is " ASC" instead of "columname ASC"

    --
    Regards,
    Alvin Bruney [Microsoft MVP ASP.NET]

    [Shameless Author plug]
    The Microsoft Office Web Components Black Book with .NET
    Now Available @ http://www.lulu.com/owc
    ----------------------------------------------------------


    "Mike Kline" <> wrote in message
    news:...
    > Hi All!
    >
    > I've this strange DataView sort bug and i can't do any sorting activities!
    > Below is my code...
    >
    > ---VB.NET Code---
    >
    > dvFinal = New DataView(objDataSet.Tables(CON_FinalTable))
    >
    > Dim strSort As String = drpOrderBy.Text & " " & drpOrderStyle.Text
    > dvFinal.Sort = strSort
    >
    > Response.Write(strSort)
    >
    > ---End VB.NET Code---
    >
    > And I got the following error...
    >
    > ---Error Message---
    >
    > Exception Details: System.IndexOutOfRangeException: Cannot find column ASC
    >
    > ---End Error Message---
    >
    > I don't know why DataView is treating sort expression "ASC" as the column
    > name!!!
    >
    > Please help!!!
    >
    > Thank you all in advance!!!
    > MK
    Alvin Bruney [MVP], Feb 14, 2005
    #2
    1. Advertising

  3. Mike Kline

    Mike Kline Guest

    Alvin Bruney [MVP] wrote:
    > Have you eliminated the possibility that drpOrderBy.Text is empty?
    > So that what actually gets passed in is " ASC" instead of "columname ASC"
    >


    Hi Alvin,

    Thanks for the reply! Yes, I've eliminated that. You can see the
    following code in my previous post...

    Response.Write(strSort)

    which indicates that I've been madly testing the value of strSort and
    tried setting the dvFinal.Sort property again and again :)

    Any other ideas?

    Thank you!
    MK
    Mike Kline, Feb 14, 2005
    #3
  4. Mike Kline

    Norman Yuan Guest

    Why do you hard code the column name in your code to test if it is a "bug"
    (very unlikely, I bet, though), like

    dvFinal.Sort="TheColumn ASC" ''TheColumn is the column you know it is
    there.

    Just curious: are drpOrderBy and drpOrderStyle DropDownLists in
    System.Web.UI.WebControls namespace? The way you name them indicates they
    are DropDownList, but DropDownList does not have property "Text". May it be
    the cause of your problem?

    "Mike Kline" <> wrote in message
    news:...
    > Alvin Bruney [MVP] wrote:
    > > Have you eliminated the possibility that drpOrderBy.Text is empty?
    > > So that what actually gets passed in is " ASC" instead of "columname

    ASC"
    > >

    >
    > Hi Alvin,
    >
    > Thanks for the reply! Yes, I've eliminated that. You can see the
    > following code in my previous post...
    >
    > Response.Write(strSort)
    >
    > which indicates that I've been madly testing the value of strSort and
    > tried setting the dvFinal.Sort property again and again :)
    >
    > Any other ideas?
    >
    > Thank you!
    > MK
    Norman Yuan, Feb 14, 2005
    #4
  5. Mike Kline

    Mike Kline Guest

    Hi Norman,

    Thanks for the reply.

    I've tested for example...

    dvFinal.Sort="CustomerCount ASC" and it worked fine. Only when I do
    through the variable.

    Also drpOrderStyle is not a DropDownList, it is a Textbox. It was named
    using drp* prefix because it WAS a DropDownList but now I'm using the
    TextBox. I just continued to use the same name so I don't have to change
    the code while I'm in the testing phase.

    Furthermore, I'm not the only one experiecing this problem (or bug???),
    for example...

    http://groups.google.co.nz/groups?h...22Sort%22+%22cannot+find+column%22+%22DESC%22

    The thing is that I can say Response.Write(strSort) and I can see the
    "CustomerCount ASC" appearing on the ASPX page. So why doesn't DataView
    is not accepting this? Why is it treating ASC or DESC commands as column
    names ?!?!?!

    Thank you!

    MK

    Norman Yuan wrote:
    > Why do you hard code the column name in your code to test if it is a "bug"
    > (very unlikely, I bet, though), like
    >
    > dvFinal.Sort="TheColumn ASC" ''TheColumn is the column you know it is
    > there.
    >
    > Just curious: are drpOrderBy and drpOrderStyle DropDownLists in
    > System.Web.UI.WebControls namespace? The way you name them indicates they
    > are DropDownList, but DropDownList does not have property "Text". May it be
    > the cause of your problem?
    >
    > "Mike Kline" <> wrote in message
    > news:...
    >
    >>Alvin Bruney [MVP] wrote:
    >>
    >>>Have you eliminated the possibility that drpOrderBy.Text is empty?
    >>>So that what actually gets passed in is " ASC" instead of "columname

    >
    > ASC"
    >
    >>Hi Alvin,
    >>
    >>Thanks for the reply! Yes, I've eliminated that. You can see the
    >>following code in my previous post...
    >>
    >>Response.Write(strSort)
    >>
    >>which indicates that I've been madly testing the value of strSort and
    >>tried setting the dvFinal.Sort property again and again :)
    >>
    >>Any other ideas?
    >>
    >>Thank you!
    >>MK

    >
    >
    >
    Mike Kline, Feb 14, 2005
    #5
  6. Mike Kline

    Mike Kline Guest

    Problem solved. It was just my stupid coding error.

    Thank you all for your time!!!

    Cheers,
    MK

    Norman Yuan wrote:
    > Why do you hard code the column name in your code to test if it is a "bug"
    > (very unlikely, I bet, though), like
    >
    > dvFinal.Sort="TheColumn ASC" ''TheColumn is the column you know it is
    > there.
    >
    > Just curious: are drpOrderBy and drpOrderStyle DropDownLists in
    > System.Web.UI.WebControls namespace? The way you name them indicates they
    > are DropDownList, but DropDownList does not have property "Text". May it be
    > the cause of your problem?
    >
    > "Mike Kline" <> wrote in message
    > news:...
    >
    >>Alvin Bruney [MVP] wrote:
    >>
    >>>Have you eliminated the possibility that drpOrderBy.Text is empty?
    >>>So that what actually gets passed in is " ASC" instead of "columname

    >
    > ASC"
    >
    >>Hi Alvin,
    >>
    >>Thanks for the reply! Yes, I've eliminated that. You can see the
    >>following code in my previous post...
    >>
    >>Response.Write(strSort)
    >>
    >>which indicates that I've been madly testing the value of strSort and
    >>tried setting the dvFinal.Sort property again and again :)
    >>
    >>Any other ideas?
    >>
    >>Thank you!
    >>MK

    >
    >
    >
    Mike Kline, Feb 14, 2005
    #6
  7. Mike Kline

    machadogj

    Joined:
    Sep 14, 2006
    Messages:
    1
    Hi, could you tell me which was the problem?

    I am having the exact same problem in .NET 2003.

    Thanks,
    machadogj, Sep 14, 2006
    #7
    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. Denzil

    Query on DataView.Sort Property

    Denzil, Oct 21, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    2,255
    Chris Taylor
    Oct 23, 2003
  2. =?Utf-8?B?RWQgQ2hpdQ==?=

    Sort an XML document using DataView

    =?Utf-8?B?RWQgQ2hpdQ==?=, Dec 14, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,871
    Scott Allen
    Dec 14, 2004
  3. nish
    Replies:
    3
    Views:
    1,597
    Gopal \(FMS, Inc.\)
    Feb 2, 2005
  4. CodeMonkey
    Replies:
    1
    Views:
    725
    joyal jhaveri
    Feb 4, 2011
  5. Navin
    Replies:
    1
    Views:
    685
    Ken Schaefer
    Sep 9, 2003
Loading...

Share This Page