Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / May 2007

Tip: Looking for answers? Try searching our database.

Multi-field sorting on dbgrid

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Luiz Guilherme - 15 May 2007 20:51 GMT
Hi,

I am a Delphi programmer and in Delphi the rows order of datagrid is given
by the sql query result, so, if I "order by" columns 1 and 2, the results
will appear ordered on the datagrid.

I am learning C# and I am trying to implement the Microsoft's suggested 5
layers design. This mean I am building BLL and DAL classes that will feed my
datagrid with DataTables.

My problem is: my "order by" clauses, so much optmized by database indexes
and ready for use, are ignored by the datagrid (or the datatable, I don't
know) and the result is sorted once again. How can I prevent this? Or, if
there isn't a solution for that, how can I order a datagrid by two or three
fields?

Thanks in advance
Marc Gravell - 16 May 2007 05:27 GMT
In COM, you sort the list. In Soviet Russia, the list sorts you! Or
more specifically, you need to get a view on the datatable (the
default [shared] view should be just fine), and set the sort string,
which can be comma delimited.

In the more generic sence (for *any* suitable data source, not just
DataTable), the IBindingListView.ApplySort() method does this job. The
poor relation is IBindingList.ApplySort() which only supports single
column.

Marc

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.