473,408 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

dataview sorting in manual order?

Is it possible to somehow sort a dataview, all on one column, but on
different variables?

That is, I have a 'Title' column in my dataview and I'd like to display
first all "Directors" (sorted), then everyone else (sorted). I've used the
'ItemBound' but can't figure out how to do this with that procedure.

Thanks in advance, any ideas are appreciated.

Jason

eg of what I'm looking for:

Name Title
===== ======
George Director
Yvonne Director
Harry Programmer
Larry Research Officer
Wilbur Secretary


Nov 18 '05 #1
7 2310
Right after you bind the dataview, do the following:

dataview.Sort = "Titles ASC, Directors ASC"

"Jason" wrote:
Is it possible to somehow sort a dataview, all on one column, but on
different variables?

That is, I have a 'Title' column in my dataview and I'd like to display
first all "Directors" (sorted), then everyone else (sorted). I've used the
'ItemBound' but can't figure out how to do this with that procedure.

Thanks in advance, any ideas are appreciated.

Jason

eg of what I'm looking for:

Name Title
===== ======
George Director
Yvonne Director
Harry Programmer
Larry Research Officer
Wilbur Secretary


Nov 18 '05 #2
Unfortunately, I get:

Exception Details: System.IndexOutOfRangeException: Cannot find column
Director.

Source Error:

Line 197:
Line 198: DGADResults.DataSource = dvCustom
Line 199: dvCustom.Sort = "title ASC, Director ASC"
Line 200: DGADResults.DataBind()
Line 201: End Sub
thoughts?
"Matt Hamilton" <Ma**********@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
Right after you bind the dataview, do the following:

dataview.Sort = "Titles ASC, Directors ASC"

"Jason" wrote:
Is it possible to somehow sort a dataview, all on one column, but on
different variables?

That is, I have a 'Title' column in my dataview and I'd like to display
first all "Directors" (sorted), then everyone else (sorted). I've used the 'ItemBound' but can't figure out how to do this with that procedure.

Thanks in advance, any ideas are appreciated.

Jason

eg of what I'm looking for:

Name Title
===== ======
George Director
Yvonne Director
Harry Programmer
Larry Research Officer
Wilbur Secretary


Nov 18 '05 #3
Jason:

You don't have a column named "Director". Change the Sort to only use
columns you do have, like Title and Name.

dataview.Sort = "Title ASC"

--
Scott
http://www.OdeToCode.com

On Wed, 1 Sep 2004 16:50:33 -0600, "Jason" <ja***@grossmans.net>
wrote:
Unfortunately, I get:

Exception Details: System.IndexOutOfRangeException: Cannot find column
Director.

Source Error:

Line 197:
Line 198: DGADResults.DataSource = dvCustom
Line 199: dvCustom.Sort = "title ASC, Director ASC"
Line 200: DGADResults.DataBind()
Line 201: End Sub
thoughts?
"Matt Hamilton" <Ma**********@discussions.microsoft.com> wrote in message
news:76**********************************@microso ft.com...
Right after you bind the dataview, do the following:

dataview.Sort = "Titles ASC, Directors ASC"

"Jason" wrote:
> Is it possible to somehow sort a dataview, all on one column, but on
> different variables?
>
> That is, I have a 'Title' column in my dataview and I'd like to display
> first all "Directors" (sorted), then everyone else (sorted). I've usedthe > 'ItemBound' but can't figure out how to do this with that procedure.
>
> Thanks in advance, any ideas are appreciated.
>
> Jason
>
> eg of what I'm looking for:
>
> Name Title
> ===== ======
> George Director
> Yvonne Director
> Harry Programmer
> Larry Research Officer
> Wilbur Secretary
>
>
>
>
>


Nov 18 '05 #4
I guess it has to be

DGADResults.DataSource = dvCustom
dvCustom.Sort = "title ASC, Name ASC"
DGADResults.DataBind()
"Jason" wrote:
Unfortunately, I get:

Exception Details: System.IndexOutOfRangeException: Cannot find column
Director.

Source Error:

Line 197:
Line 198: DGADResults.DataSource = dvCustom
Line 199: dvCustom.Sort = "title ASC, Director ASC"
Line 200: DGADResults.DataBind()
Line 201: End Sub
thoughts?
"Matt Hamilton" <Ma**********@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
Right after you bind the dataview, do the following:

dataview.Sort = "Titles ASC, Directors ASC"

"Jason" wrote:
Is it possible to somehow sort a dataview, all on one column, but on
different variables?

That is, I have a 'Title' column in my dataview and I'd like to display
first all "Directors" (sorted), then everyone else (sorted). I've used the 'ItemBound' but can't figure out how to do this with that procedure.

Thanks in advance, any ideas are appreciated.

Jason

eg of what I'm looking for:

Name Title
===== ======
George Director
Yvonne Director
Harry Programmer
Larry Research Officer
Wilbur Secretary



Nov 18 '05 #5
First off, thanks to everyone who's responded, I think we're almost there:

Alright, so I've sorted dataviews before by a column name like this without
a problem. What I'm trying to get however is a sorted list of all rows
whose column 'title' has a value of "Director" -THEN- list the rest of the
rows in normal sorted order.

That is, just as in my example below, although Yvonne and George should not
be at the top of the list because their names fall alphabetically below
'Barry', because they have a title='Director' value, I would like them to be
on the top of the list first. Following all of these Directors, Barry,
Larry, and Wilbur are sorted normally.

Name Title
===== ======
George Director
Yvonne Director
Barry Programmer
Larry Research Officer
Wilbur Secretary

dataview.Sort = "Title ASC" won't cut it, nor would dvCustom.Sort = "title
ASC, Name ASC" because my data could contain a title='Associate something'
that would take the top spot instead of any "Director".

"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:uh********************************@4ax.com...
Jason:

You don't have a column named "Director". Change the Sort to only use
columns you do have, like Title and Name.

dataview.Sort = "Title ASC"

--
Scott
http://www.OdeToCode.com

On Wed, 1 Sep 2004 16:50:33 -0600, "Jason" <ja***@grossmans.net>
wrote:
Unfortunately, I get:

Exception Details: System.IndexOutOfRangeException: Cannot find column
Director.

Source Error:

Line 197:
Line 198: DGADResults.DataSource = dvCustom
Line 199: dvCustom.Sort = "title ASC, Director ASC"
Line 200: DGADResults.DataBind()
Line 201: End Sub
thoughts?
"Matt Hamilton" <Ma**********@discussions.microsoft.com> wrote in message
news:76**********************************@microso ft.com...
Right after you bind the dataview, do the following:

dataview.Sort = "Titles ASC, Directors ASC"

"Jason" wrote:

> Is it possible to somehow sort a dataview, all on one column, but on
> different variables?
>
> That is, I have a 'Title' column in my dataview and I'd like to display > first all "Directors" (sorted), then everyone else (sorted). I've
usedthe
> 'ItemBound' but can't figure out how to do this with that procedure.
>
> Thanks in advance, any ideas are appreciated.
>
> Jason
>
> eg of what I'm looking for:
>
> Name Title
> ===== ======
> George Director
> Yvonne Director
> Harry Programmer
> Larry Research Officer
> Wilbur Secretary
>
>
>
>
>

Nov 18 '05 #6
Ah, thats a bit tricker. There is no built in way to do this easily
but here is something to try...

Add an additional column to the underlying DataTable. When the Title
is Director, set the value of this column to 1, when the Title is not
a director, set the value to 2. Then you could use a Sort expression
like:

dv.Sort = "SortColumn ASC, Name ASC";

The additional column could be a computed column. Add the column
programatically:

dataTable.Columns.Add("SortColumn", typeof(int), expr);

Where expr is an expression like:

"IIF(Title='Director', 1, 2)"
HTH,

--
Scott
http://www.OdeToCode.com

On Thu, 2 Sep 2004 08:04:51 -0600, "Jason" <ja***@grossmans.net>
wrote:
First off, thanks to everyone who's responded, I think we're almost there:

Alright, so I've sorted dataviews before by a column name like this without
a problem. What I'm trying to get however is a sorted list of all rows
whose column 'title' has a value of "Director" -THEN- list the rest of the
rows in normal sorted order.

That is, just as in my example below, although Yvonne and George should not
be at the top of the list because their names fall alphabetically below
'Barry', because they have a title='Director' value, I would like them to be
on the top of the list first. Following all of these Directors, Barry,
Larry, and Wilbur are sorted normally.

Name Title
===== ======
George Director
Yvonne Director
Barry Programmer
Larry Research Officer
Wilbur Secretary

dataview.Sort = "Title ASC" won't cut it, nor would dvCustom.Sort = "title
ASC, Name ASC" because my data could contain a title='Associate something'
that would take the top spot instead of any "Director".

"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:uh********************************@4ax.com.. .
Jason:

You don't have a column named "Director". Change the Sort to only use
columns you do have, like Title and Name.

dataview.Sort = "Title ASC"

--
Scott
http://www.OdeToCode.com

On Wed, 1 Sep 2004 16:50:33 -0600, "Jason" <ja***@grossmans.net>
wrote:
>Unfortunately, I get:
>
>Exception Details: System.IndexOutOfRangeException: Cannot find column
>Director.
>
>Source Error:
>
>Line 197:
>Line 198: DGADResults.DataSource = dvCustom
>Line 199: dvCustom.Sort = "title ASC, Director ASC"
>Line 200: DGADResults.DataBind()
>Line 201: End Sub
>
>
>thoughts?
>
>
>"Matt Hamilton" <Ma**********@discussions.microsoft.com> wrote in message
>news:76**********************************@microso ft.com...
>> Right after you bind the dataview, do the following:
>>
>> dataview.Sort = "Titles ASC, Directors ASC"
>>
>> "Jason" wrote:
>>
>> > Is it possible to somehow sort a dataview, all on one column, but on
>> > different variables?
>> >
>> > That is, I have a 'Title' column in my dataview and I'd like todisplay >> > first all "Directors" (sorted), then everyone else (sorted). I'veused >the
>> > 'ItemBound' but can't figure out how to do this with that procedure.
>> >
>> > Thanks in advance, any ideas are appreciated.
>> >
>> > Jason
>> >
>> > eg of what I'm looking for:
>> >
>> > Name Title
>> > ===== ======
>> > George Director
>> > Yvonne Director
>> > Harry Programmer
>> > Larry Research Officer
>> > Wilbur Secretary
>> >
>> >
>> >
>> >
>> >
>


Nov 18 '05 #7
Good idea, I'll give that a whirl and it should suit my needs just fine.

Thanks alot!

Jay

"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:ai********************************@4ax.com...
Ah, thats a bit tricker. There is no built in way to do this easily
but here is something to try...

Add an additional column to the underlying DataTable. When the Title
is Director, set the value of this column to 1, when the Title is not
a director, set the value to 2. Then you could use a Sort expression
like:

dv.Sort = "SortColumn ASC, Name ASC";

The additional column could be a computed column. Add the column
programatically:

dataTable.Columns.Add("SortColumn", typeof(int), expr);

Where expr is an expression like:

"IIF(Title='Director', 1, 2)"
HTH,

--
Scott
http://www.OdeToCode.com

On Thu, 2 Sep 2004 08:04:51 -0600, "Jason" <ja***@grossmans.net>
wrote:
First off, thanks to everyone who's responded, I think we're almost there:
Alright, so I've sorted dataviews before by a column name like this withouta problem. What I'm trying to get however is a sorted list of all rows
whose column 'title' has a value of "Director" -THEN- list the rest of therows in normal sorted order.

That is, just as in my example below, although Yvonne and George should notbe at the top of the list because their names fall alphabetically below
'Barry', because they have a title='Director' value, I would like them to beon the top of the list first. Following all of these Directors, Barry,
Larry, and Wilbur are sorted normally.

Name Title
===== ======
George Director
Yvonne Director
Barry Programmer
Larry Research Officer
Wilbur Secretary

dataview.Sort = "Title ASC" won't cut it, nor would dvCustom.Sort = "titleASC, Name ASC" because my data could contain a title='Associate something'that would take the top spot instead of any "Director".

"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:uh********************************@4ax.com.. .
Jason:

You don't have a column named "Director". Change the Sort to only use
columns you do have, like Title and Name.

dataview.Sort = "Title ASC"

--
Scott
http://www.OdeToCode.com

On Wed, 1 Sep 2004 16:50:33 -0600, "Jason" <ja***@grossmans.net>
wrote:

>Unfortunately, I get:
>
>Exception Details: System.IndexOutOfRangeException: Cannot find column
>Director.
>
>Source Error:
>
>Line 197:
>Line 198: DGADResults.DataSource = dvCustom
>Line 199: dvCustom.Sort = "title ASC, Director ASC"
>Line 200: DGADResults.DataBind()
>Line 201: End Sub
>
>
>thoughts?
>
>
>"Matt Hamilton" <Ma**********@discussions.microsoft.com> wrote in message >news:76**********************************@microso ft.com...
>> Right after you bind the dataview, do the following:
>>
>> dataview.Sort = "Titles ASC, Directors ASC"
>>
>> "Jason" wrote:
>>
>> > Is it possible to somehow sort a dataview, all on one column, but on >> > different variables?
>> >
>> > That is, I have a 'Title' column in my dataview and I'd like to

display
>> > first all "Directors" (sorted), then everyone else (sorted). I've

used
>the
>> > 'ItemBound' but can't figure out how to do this with that procedure. >> >
>> > Thanks in advance, any ideas are appreciated.
>> >
>> > Jason
>> >
>> > eg of what I'm looking for:
>> >
>> > Name Title
>> > ===== ======
>> > George Director
>> > Yvonne Director
>> > Harry Programmer
>> > Larry Research Officer
>> > Wilbur Secretary
>> >
>> >
>> >
>> >
>> >
>

Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: jwedel_stolo | last post by:
Hi I'm creating a dataview "on the fly" in order to sort some data prior to writing out the information to a MS SQL table I have used two methods in order to determine the sort order of the...
9
by: Raymond Lewallen | last post by:
I have a dataview in which the sort property will not sort the dataview. Here's is a simple scenario similar to what I am doing: Class Foo Private Function Retrieve() As DataView ' Returns a...
8
by: Saputra | last post by:
Does anyone know how to sort a data view numerically? By default, when you sort a field from a table in a database, it sorts it in alpha-numerical order. In MS Access, sort is by alpha-numeric,...
0
by: Nathan Franklin | last post by:
Hello Guys, I have been trying to work this our for so long, but I just can't seem to find the answer. I am loading a datatable from a an access database using an oledbdataadapter. I then...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.