2.0 GridView .. Sorting Question

S

sloan

Ok, I've gotten somewhat handy with the new GridView.
And I have it bound to a business object datasource, via the
ObjectDataSource.

Lets say I have 3 databound columns
EmpID, LastName,FirstName

I have it working where.... If I click the Header, that it will sort based
on the Header I click.
I even have DESC working if they click the same column header twice.

...

Now, let's say I want to NOT use the Headers. I want to setup 3 ddl (drop
down lists) ...something like this:

Sort By: LastName
(then by): FirstName
(then by): EmpID

And then sort the data.....so I get a sort string like this
"LastName,FirstName,EmpID"

To add some more info, lets say I have 450 employees, and my pagesize/count
is set to 100.
(Aka, 5 pages of data..to hold 100,100,100,100, and 50 employees)


My example is trivial, my data is more complicated than this, fyi.

Which/What object handles the sorting from then on out?

I specifically have a strongly typed DataSet as my source for my
ObjectDataSource, because I didn't want to write a super complicated
IComparer.

Can I sort the dataset.... then rebind it to the ObjectDataSource?

Aka, how can I sort when I want to setup the sort ..outside of the GridView
itself.

....

Thanks.
 
D

DKode

the way I do it with datagrids in 1.1, is from the dataset i get
defaultview:

DataView dv = DataSet.DefaultView;

then you can do a dv.Sort

in your gridview OnSort, get the dataview, sort it and re-bind it to
the gridview. you can also supply multiple sort options in the dataview
like you mentioned: LastName,FirstName,EmpID

this might be different for the GridView, I havent played with that
control yet, so you get the idea.
 

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,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top