473,395 Members | 1,452 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,395 software developers and data experts.

default sort on gridview load

For performance reasons i can not set a sort order on a dataset returned from
a stored procedure. Ideally in the sp i'd set the company name as the order
and just load the gridview, however the joins are very complicated and this
causes the sp to take 20 time (at least) longer than when no ordering is
specified. I would create a temp table and sort this for the return, however,
ado.net can not see a temp table because it does not exist at the conclustion
of the sp. I REALLY do not want to use an inline adhoc query that joins 15
table and uses derived result sets to get all the information. The sp
performs very well so long as no attempt to order the result is made.

So here is my issue:
I need to set the default order to company name on the result set on initial
datagrid load. Is there a way to do this? And where? and How?

I think this one is an issue some others have faced and i'd really like you
help.

Thanks!
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
Jan 29 '07 #1
4 10892
1. Create a "DataView" from your "DataSource"
2. Set the sort order and/or filters in the DataView. (see the .Sort
and .RowFilter properties)
3. Bind the dataview (not the datasource) to your GridView

Jan 29 '07 #2
will sorting then be handled as usual or are there extra steps needed when a
column is selected for alternate sorting such as the older datagrid?
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
"GroupReader" wrote:
1. Create a "DataView" from your "DataSource"
2. Set the sort order and/or filters in the DataView. (see the .Sort
and .RowFilter properties)
3. Bind the dataview (not the datasource) to your GridView

Jan 29 '07 #3
When the user clicks on a column (to sort that column), you'll have to
handle the appropriate "sorting" event.

In the "sorting" event-handler, you need to:
- requery the data
- create a dataView from the dataset or datatable
- set the sorting on the dataview
- bind the dataview to the grid

Additionally, there are steps you need to take to set the correct up/
down arrow in the grid column header if you want a graphic to show
which column is sorted. Some people use images. Some people use
these unicode chars:&#9650" and "&#9660" to show up/down arrows. For
compatibility reasons, the images are best. I don't have the code in
front of me, but I remember being very "surprised" at how not-so-easy
this was.


Jan 30 '07 #4
ok same as a datagrid.
thnaks
kes
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
"GroupReader" wrote:
When the user clicks on a column (to sort that column), you'll have to
handle the appropriate "sorting" event.

In the "sorting" event-handler, you need to:
- requery the data
- create a dataView from the dataset or datatable
- set the sorting on the dataview
- bind the dataview to the grid

Additionally, there are steps you need to take to set the correct up/
down arrow in the grid column header if you want a graphic to show
which column is sorted. Some people use images. Some people use
these unicode chars:â–²" and "â–¼" to show up/down arrows. For
compatibility reasons, the images are best. I don't have the code in
front of me, but I remember being very "surprised" at how not-so-easy
this was.


Jan 30 '07 #5

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

Similar topics

6
by: mcollier | last post by:
I have some VB6 code that calls a SELECT query in Microsoft Access. When I run the query from access, the results appear in not particular order. However, when I call the query from VB6, via ADO,...
2
by: Daves | last post by:
I have a gridview displaying News items and fetches the data through a (little complicated) sql stored procedure... The sorting seems to be done in the gridview since there is no sorting...
0
by: Morten | last post by:
Hi! I'm using a gridview to display properties for a number of custom made objects. E.g. "firstname" and "lastname" of a user object. I'd like to be able to sort my object list based on which...
4
by: CSharpguy | last post by:
I have a grid on my webform with 10 columns, I need to allow the user to sort the columns when they click on the header. My grid is populated byt a dataset and not any typed datasets,...
1
by: keithb | last post by:
I have a working ASP.NET 2.0 application that uses a GridView control. How can I enable the feature that allows a user to click on a column heading and sort the contents by the information in that...
0
by: rmgalante | last post by:
Hi, I've been experimenting with the ASP.Net GridView and encountered some interesting issues that I thought I would share. I have a page that loads a GridView with a generic collection of...
0
by: Mehdi6002 | last post by:
Hi Guys, How can I sort my GridView if I bind it to a business object ??? My Object Data Source selected method returns a collection of my business object as follows: public...
1
by: ntuyen01 | last post by:
Hi All, Is there a way to make the first row in the Girdview as my default select row, with the highlight color. Thanks and Regards
3
by: Peter | last post by:
I have a GridView which is populated by List<ofObjects> Does anyone have example of how to sort the columns of this GridView? I have found examples without DataSourceControl but these use...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.