473,795 Members | 2,892 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what's the best way

Hello...
I have a question related to performance.
Being new to asp.net & vp programming, I put together
a webform that displays columns of data in a datagrid.
Users can sort by the header label.

QUESTION: When they click to sort, I run a new
stored procedure to return the resorted data...

Should I only get the data once and query the
disconnected dataset.. and if so .. can someone
point me in the right direction.

Thanks in advance....
Jan 20 '06 #1
7 1212
KJ
Get the data once, and just use a DataView to sort, like so:

//(pseudo C#), in SortCommand event handler
DataSet ds = GetMyDataSet(); // your function here
DataView dv = new DataView (ds.Tables[0]); //first table
v.Sort = "Clicked Column Name"; //column name of the table to sort on
MyDataGrid.Data Source = dv; //set the sorted view as the data source to
the datagrid
MyDataGrid.Data Bind(); // bind the grid to the view

Note: Sort direction may also be changed by appending " ASC" or " DESC"
to the v.Sort assigned value.

Jan 20 '06 #2
Thanks KJ.
I will try to work through your suggestion.
I have one more question if you don't mind...
Is this the best..(fastest) way to retrive data into a dataset...

Dim sTextBranchCoun ts As String = "dcc.dbo.afCoun t_Display" 'Stored Proc to
return the Pre Processed Data

Dim sConn As String =
"SERVER=localho st;UID=*****;PA SSWORD=*****;DA TABASE=*****;"

Dim dsBC As DataSet = New DataSet

Dim cmdBC As SqlDataAdapter = New SqlDataAdapter( sTextBranchCoun ts, sConn)

cmdBC.SelectCom mand.CommandTyp e = CommandType.Sto redProcedure

dsBC.Clear()

cmdBC.Fill(dsBC , cmdBC.SelectCom mand.ToString)

Me.dgBranchCoun ts.DataSource = dsBC

Me.dgFleetInspe ctions.DataBind ()

Thanks in advance...
"KJ" <n_**********@m ail.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Get the data once, and just use a DataView to sort, like so:

//(pseudo C#), in SortCommand event handler
DataSet ds = GetMyDataSet(); // your function here
DataView dv = new DataView (ds.Tables[0]); //first table
v.Sort = "Clicked Column Name"; //column name of the table to sort on
MyDataGrid.Data Source = dv; //set the sorted view as the data source to
the datagrid
MyDataGrid.Data Bind(); // bind the grid to the view

Note: Sort direction may also be changed by appending " ASC" or " DESC"
to the v.Sort assigned value.

Jan 20 '06 #3
KJ
Your way of getting the job done looks fine. Note that the Framework is
quite flexible in that there are many ways to achive the same result.

One thing to also get in the habit of is to call the Dispose method of
any SqlDataAdapter, SqlCommand, SqlConnection, DataSet, or any other
object you instantiate that provides a Dispose() method.

This will ensure that your objects get cleaned up asap, releasing any
unmanaged resources (such as COM objects) used by them under the hood.

Jan 20 '06 #4
Bob,

I concur with KJ the Dataview is the way to go. I am attaching some code
you may find useful. This is from a report from one of my websites that
uses dataview to sort on grid clicks. NationalConfere ncetable is a
datatable that in my code is stored in the application object but you can
get your datatable from just about any persistent storage area Application,
Session, Cache, etc.. I hope this helps you.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

ReportDataGrid. DataSource = Application ("NationalConfe rencetable")

ReportDataGrid. DataBind()

End Sub

'sorting code to use headers to sort data.

Private Sub ReportDataGrid_ SortCommand(ByV al source As System.Object, ByVal
e As System.Web.UI.W ebControls.Data GridSortCommand EventArgs) Handles
ReportDataGrid. SortCommand

Dim firstView As DataView = New DataView(Applic ation
("NationalConfe rencetable"))

firstView.Sort = e.SortExpressio n

ReportDataGrid. DataSource = firstView

ReportDataGrid. DataBind()

End Sub


"John 3:16" <bo****@tricoeq uipment.com> wrote in message
news:u6******** *****@TK2MSFTNG P09.phx.gbl...
Hello...
I have a question related to performance.
Being new to asp.net & vp programming, I put together
a webform that displays columns of data in a datagrid.
Users can sort by the header label.

QUESTION: When they click to sort, I run a new
stored procedure to return the resorted data...

Should I only get the data once and query the
disconnected dataset.. and if so .. can someone
point me in the right direction.

Thanks in advance....

Jan 20 '06 #5
Thanks KJ... I will discipline myself to you the dispose method whenenver
possible.
"KJ" <n_**********@m ail.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
Your way of getting the job done looks fine. Note that the Framework is
quite flexible in that there are many ways to achive the same result.

One thing to also get in the habit of is to call the Dispose method of
any SqlDataAdapter, SqlCommand, SqlConnection, DataSet, or any other
object you instantiate that provides a Dispose() method.

This will ensure that your objects get cleaned up asap, releasing any
unmanaged resources (such as COM objects) used by them under the hood.

Jan 20 '06 #6
The biggest filtered set is just under 1,000 records.
It's currently taking 5-7 sec. to retrieve the data.
I'd like to do this once when they open the webform and
then when they sort, I'd like the data to be there already and
just be able to change the sort on that data.

"Spam Catcher" <sp**********@r ogers.com> wrote in message
news:Xn******** *************** ***********@127 .0.0.1...
"John 3:16" <bo****@tricoeq uipment.com> wrote in news:u6p4wefHGH A.344
@TK2MSFTNGP09.p hx.gbl:
Should I only get the data once and query the
disconnected dataset.. and if so .. can someone
point me in the right direction.


Depends on how big your data set is...

--
Stan Kee (sp**********@r ogers.com)

Jan 23 '06 #7
Thanks Steve.
I will work with your example and try to understand how this works.
Thanks again,
Bob.

"Steve Mauldin" <st**********@h otmail.com> wrote in message
news:u0******** ********@TK2MSF TNGP11.phx.gbl. ..
Bob,

I concur with KJ the Dataview is the way to go. I am attaching some code
you may find useful. This is from a report from one of my websites that
uses dataview to sort on grid clicks. NationalConfere ncetable is a
datatable that in my code is stored in the application object but you can
get your datatable from just about any persistent storage area
Application,
Session, Cache, etc.. I hope this helps you.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

ReportDataGrid. DataSource = Application ("NationalConfe rencetable")

ReportDataGrid. DataBind()

End Sub

'sorting code to use headers to sort data.

Private Sub ReportDataGrid_ SortCommand(ByV al source As System.Object,
ByVal
e As System.Web.UI.W ebControls.Data GridSortCommand EventArgs) Handles
ReportDataGrid. SortCommand

Dim firstView As DataView = New DataView(Applic ation
("NationalConfe rencetable"))

firstView.Sort = e.SortExpressio n

ReportDataGrid. DataSource = firstView

ReportDataGrid. DataBind()

End Sub


"John 3:16" <bo****@tricoeq uipment.com> wrote in message
news:u6******** *****@TK2MSFTNG P09.phx.gbl...
Hello...
I have a question related to performance.
Being new to asp.net & vp programming, I put together
a webform that displays columns of data in a datagrid.
Users can sort by the header label.

QUESTION: When they click to sort, I run a new
stored procedure to return the resorted data...

Should I only get the data once and query the
disconnected dataset.. and if so .. can someone
point me in the right direction.

Thanks in advance....


Jan 23 '06 #8

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

Similar topics

23
2819
by: darwinist | last post by:
What PHP Represents There is no shortage of complaints one could make about php as a language, and although the list does shrink with each release, some of them are inherent to the origins and development process of this, the most popular of the web-based, server-side, glue-languages. That said, most descriptions of what is good about php, fail to do it justice. Although they are generally enthusiastic and sometimes fanatical, no...
226
12717
by: Stephen C. Waterbury | last post by:
This seems like it ought to work, according to the description of reduce(), but it doesn't. Is this a bug, or am I missing something? Python 2.3.2 (#1, Oct 20 2003, 01:04:35) on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> d1 = {'a':1} >>> d2 = {'b':2} >>> d3 = {'c':3}
125
14860
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from software giant such as Microsoft SQL Server, Oracle, and Sybase? Is PostgreSQL reliable enough to be used for high-end commercial application? Thanks
3
8883
by: David Logan | last post by:
I have an application using sockets, and it uses the asynchronous method for receiving (and others, but receiving is the basic problem.) In short, I want: class someClass: Form { mySocketClass sss; ...
6
2005
by: Mark Broadbent | last post by:
this might sound like an obvious question but I have found that usually these two evolve at the same time. One of the biggest reasons for creating the abstraction in the first place (in my opinion) is to create a reusable framework that can be applied to similar projects. However I have found that if an abstraction is created first during the development phase, when the implementation is occurring, the functionality or intended behaviour...
6
1826
by: jhooper71 | last post by:
It's been recommended to me to use a webservice and XML for the data manipulation layer for web applications in .NET 1.1. I was thinking I could use the web service to extend the database interface to a Smart Phone/Treo solution eventually. I would like to create our apps in the most current development environment but, do I abandon the webservice-->Dataset--> XML -->Http-->XML --> dataset -->gridview methodology? Is there a better...
4
4911
by: Ron Brennan | last post by:
Good evening, Windows 2000, JDK 1.5. What opinions do people have on what way and tool programmaticly produces the best quality thumbnails from larger images? On the web I've seen Java Advanced Imaging (JAI), ImageMagick, and GIMP all praised as best in different places.
98
4627
by: tjb | last post by:
I often see code like this: /// <summary> /// Removes a node. /// </summary> /// <param name="node">The node to remove.</param> public void RemoveNode(Node node) { <...> }
2
1912
by: kbutterly | last post by:
All, I have a menu which contains Category as the master and Product as the child. When I click on a Category in the menu, I want one formView control, fvpc, to show, and then when I click on a Product, I want a different formview, fvp, to show. Is it best to have the two forms on separate pages, productView.aspx
19
4646
by: jsanshef | last post by:
Hi, after a couple of days of script debugging, I kind of found that some assumptions I was doing about the memory complexity of my classes are not true. I decided to do a simple script to isolate the problem: class MyClass: def __init__(self,s): self.mystring = s
0
9672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10438
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10214
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10164
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9042
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7540
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.