473,563 Members | 2,897 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2323
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.IndexOut OfRangeExceptio n: Cannot find column
Director.

Source Error:

Line 197:
Line 198: DGADResults.Dat aSource = dvCustom
Line 199: dvCustom.Sort = "title ASC, Director ASC"
Line 200: DGADResults.Dat aBind()
Line 201: End Sub
thoughts?
"Matt Hamilton" <Ma**********@d iscussions.micr osoft.com> wrote in message
news:76******** *************** ***********@mic rosoft.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***@grossman s.net>
wrote:
Unfortunatel y, I get:

Exception Details: System.IndexOut OfRangeExceptio n: Cannot find column
Director.

Source Error:

Line 197:
Line 198: DGADResults.Dat aSource = dvCustom
Line 199: dvCustom.Sort = "title ASC, Director ASC"
Line 200: DGADResults.Dat aBind()
Line 201: End Sub
thoughts?
"Matt Hamilton" <Ma**********@d iscussions.micr osoft.com> wrote in message
news:76******* *************** ************@mi crosoft.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.Dat aSource = dvCustom
dvCustom.Sort = "title ASC, Name ASC"
DGADResults.Dat aBind()
"Jason" wrote:
Unfortunately, I get:

Exception Details: System.IndexOut OfRangeExceptio n: Cannot find column
Director.

Source Error:

Line 197:
Line 198: DGADResults.Dat aSource = dvCustom
Line 199: dvCustom.Sort = "title ASC, Director ASC"
Line 200: DGADResults.Dat aBind()
Line 201: End Sub
thoughts?
"Matt Hamilton" <Ma**********@d iscussions.micr osoft.com> wrote in message
news:76******** *************** ***********@mic rosoft.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='Associat e something'
that would take the top spot instead of any "Director".

"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:uh******** *************** *********@4ax.c om...
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***@grossman s.net>
wrote:
Unfortunatel y, I get:

Exception Details: System.IndexOut OfRangeExceptio n: Cannot find column
Director.

Source Error:

Line 197:
Line 198: DGADResults.Dat aSource = dvCustom
Line 199: dvCustom.Sort = "title ASC, Director ASC"
Line 200: DGADResults.Dat aBind()
Line 201: End Sub
thoughts?
"Matt Hamilton" <Ma**********@d iscussions.micr osoft.com> wrote in message
news:76******* *************** ************@mi crosoft.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.Colum ns.Add("SortCol umn", typeof(int), expr);

Where expr is an expression like:

"IIF(Title='Dir ector', 1, 2)"
HTH,

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

On Thu, 2 Sep 2004 08:04:51 -0600, "Jason" <ja***@grossman s.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.Sor t = "Title ASC" won't cut it, nor would dvCustom.Sort = "title
ASC, Name ASC" because my data could contain a title='Associat e 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***@grossman s.net>
wrote:
>Unfortunatel y, I get:
>
>Exception Details: System.IndexOut OfRangeExceptio n: Cannot find column
>Director.
>
>Source Error:
>
>Line 197:
>Line 198: DGADResults.Dat aSource = dvCustom
>Line 199: dvCustom.Sort = "title ASC, Director ASC"
>Line 200: DGADResults.Dat aBind()
>Line 201: End Sub
>
>
>thoughts?
>
>
>"Matt Hamilton" <Ma**********@d iscussions.micr osoft.com> wrote in message
>news:76******* *************** ************@mi crosoft.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.c om...
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.Colum ns.Add("SortCol umn", typeof(int), expr);

Where expr is an expression like:

"IIF(Title='Dir ector', 1, 2)"
HTH,

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

On Thu, 2 Sep 2004 08:04:51 -0600, "Jason" <ja***@grossman s.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.Sor t = "Title ASC" won't cut it, nor would dvCustom.Sort = "titleASC, Name ASC" because my data could contain a title='Associat e 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***@grossman s.net>
wrote:

>Unfortunatel y, I get:
>
>Exception Details: System.IndexOut OfRangeExceptio n: Cannot find column
>Director.
>
>Source Error:
>
>Line 197:
>Line 198: DGADResults.Dat aSource = dvCustom
>Line 199: dvCustom.Sort = "title ASC, Director ASC"
>Line 200: DGADResults.Dat aBind()
>Line 201: End Sub
>
>
>thoughts?
>
>
>"Matt Hamilton" <Ma**********@d iscussions.micr osoft.com> wrote in message >news:76******* *************** ************@mi crosoft.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
2564
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 DataView. (I'm writing in C# with the v1.1.4322 of the .NET Framework, in Window2K server"). First of all, here are the two methods I have used in order to...
9
2086
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 DataView with 2 columns and 3 rows Dim ADOHelper As New DAL.ADOHelper Return ADOHelper.GetMyDataview() End
8
661
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, that is, numbers sort from 1, 10 ,11, 1X, 2, 21, 2X, etc. I want VB.NET to sort a column in data view numerically, so it goes 1 - 9, 10 - 19, 20 -...
0
1827
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 assign the datatable.dataview to my datagrid.datasource member so it will display my results.. I need to give the user an option to change the order...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7950
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.