DataView Sort Bug

M

Mike Kline

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
 
A

Alvin Bruney [MVP]

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
 
M

Mike Kline

Alvin said:
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
 
N

Norman Yuan

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?
 
M

Mike Kline

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
 
M

Mike Kline

Problem solved. It was just my stupid coding error.

Thank you all for your time!!!

Cheers,
MK
 
Joined
Sep 14, 2006
Messages
1
Reaction score
0
Hi, could you tell me which was the problem?

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

Thanks,
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top