By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,750 Members | 1,367 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,750 IT Pros & Developers. It's quick & easy.

Sorting a Strong Typed Dataset

P: n/a
Hi, I am looking for a way to sort a strong typed dataset. It would seem the most straightforward way is to use a dataview. The only problem is when I use the dataview I seem to loose the strong typed properties from my original dataset

Anyone that can point me to an example of how to sort my dataset and maintain the use of my typed properties would be greatly appreciated

Thank,
Freeon
Nov 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Cor
Hi Freeon,

By using a dataview you are not sorting the dataset.

As it said, it is a view on the data from the dataset.

You also can use a rowfilter and that is exact what it says, a filter.

But if the problem is different tell it?

Cor
Nov 22 '05 #2

P: n/a
Right, I can use the .sort property change the order rows are accessed in the dataview. This works great but I loose the Strong Typed Names from the original dataset (unless I'm missing something) when I use the dataview

'************************
'Here is a quick sample (Unsorted)
Dim drHeader As CUnit.HeaderRo
Dim objUnits As New CUnit(ConnectionString) 'This is a Strong Typed Dataset (.xsd
objUnits.Loa

For Each drHeader In objUnits.Heade
Writeline drHeader.LK_I
Nex

'************************
'Now Here is the sorted example where I loose Strong Typed Properties from the Unit Datase
Dim drHeader As DataRowVie
Dim objUnits As New CUnit(ConnectionString) 'This is a Strong Typed Dataset (.xsd
objUnits.Loa

Dim dvHeader as New DataView(objUnits.Header
dvHeader.Sort = "LK_id desc

For Each drHeader In dvHeade
Writeline drHeader("LK_ID") 'This works but I lost the ability to use the typed property name (LK_ID)
Nex
'************************

The second example is 90% of what I want to do.

Just incase the 10% is not so clear this is how you access a non-typed datase
Writeline drHeader("LK_ID"
and this is how you access a typed dataset
Writeline drHeader.LK_I

I can't figure out how to sort a dataset while maintaining the typed property names. Usually I would not care, but I have allot of class' that need to be sorted a second way and don't want to rewrite all the UI translation code

Thanks in advance
Freeo

----- Cor wrote: ----

Hi Freeon

By using a dataview you are not sorting the dataset

As it said, it is a view on the data from the dataset

You also can use a rowfilter and that is exact what it says, a filter

But if the problem is different tell it

Co

Nov 22 '05 #3

P: n/a
Cor
Hi Freeon,

I have seen you have posted this to a lot of groups, so I do not know if you
have your answer.

The typed dataset is mostly (when we see it in this newsgroup) an
automaticly by Microsoft as a wizard build dataset.

I never saw that as a wizard for the dataview.

There should be posibilities to make your own strongly typed dataview.

Than you can do when you do it right instead of dv("myItem"), dv.myItem.

That is not something I would spent much time on.

(There are of course more posibilities using the binding context from the
dataset, but that is also something that if I need the syntax above I would
not spent to much time for)

Just my thought,

Cor

"Freeon" <an*******@discussions.microsoft.com> schreef in bericht
news:E1**********************************@microsof t.com...
Right, I can use the .sort property change the order rows are accessed in the dataview. This works great but I loose the Strong Typed Names from the
original dataset (unless I'm missing something) when I use the dataview.
'*************************
'Here is a quick sample (Unsorted):
Dim drHeader As CUnit.HeaderRow
Dim objUnits As New CUnit(ConnectionString) 'This is a Strong Typed Dataset (.xsd) objUnits.Load

For Each drHeader In objUnits.Header
Writeline drHeader.LK_ID
Next

'*************************
'Now Here is the sorted example where I loose Strong Typed Properties from the Unit Dataset Dim drHeader As DataRowView
Dim objUnits As New CUnit(ConnectionString) 'This is a Strong Typed Dataset (.xsd) objUnits.Load

Dim dvHeader as New DataView(objUnits.Header)
dvHeader.Sort = "LK_id desc"

For Each drHeader In dvHeader
Writeline drHeader("LK_ID") 'This works but I lost the ability to use the typed property name (LK_ID). Next
'*************************

The second example is 90% of what I want to do.

Just incase the 10% is not so clear this is how you access a non-typed dataset Writeline drHeader("LK_ID")
and this is how you access a typed dataset:
Writeline drHeader.LK_ID
I can't figure out how to sort a dataset while maintaining the typed property names. Usually I would not care, but I have allot of class' that
need to be sorted a second way and don't want to rewrite all the UI
translation code.
Thanks in advance,
Freeon

----- Cor wrote: -----

Hi Freeon,

By using a dataview you are not sorting the dataset.

As it said, it is a view on the data from the dataset.

You also can use a rowfilter and that is exact what it says, a filter.
But if the problem is different tell it?

Cor

Nov 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.