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

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 1201
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.DataSource = dv; //set the sorted view as the data source to
the datagrid
MyDataGrid.DataBind(); // 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 sTextBranchCounts As String = "dcc.dbo.afCount_Display" 'Stored Proc to
return the Pre Processed Data

Dim sConn As String =
"SERVER=localhost;UID=*****;PASSWORD=*****;DATABAS E=*****;"

Dim dsBC As DataSet = New DataSet

Dim cmdBC As SqlDataAdapter = New SqlDataAdapter(sTextBranchCounts, sConn)

cmdBC.SelectCommand.CommandType = CommandType.StoredProcedure

dsBC.Clear()

cmdBC.Fill(dsBC, cmdBC.SelectCommand.ToString)

Me.dgBranchCounts.DataSource = dsBC

Me.dgFleetInspections.DataBind()

Thanks in advance...
"KJ" <n_**********@mail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.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.DataSource = dv; //set the sorted view as the data source to
the datagrid
MyDataGrid.DataBind(); // 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. NationalConferencetable 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.EventArgs) Handles MyBase.Load

ReportDataGrid.DataSource = Application ("NationalConferencetable")

ReportDataGrid.DataBind()

End Sub

'sorting code to use headers to sort data.

Private Sub ReportDataGrid_SortCommand(ByVal source As System.Object, ByVal
e As System.Web.UI.WebControls.DataGridSortCommandEvent Args) Handles
ReportDataGrid.SortCommand

Dim firstView As DataView = New DataView(Application
("NationalConferencetable"))

firstView.Sort = e.SortExpression

ReportDataGrid.DataSource = firstView

ReportDataGrid.DataBind()

End Sub


"John 3:16" <bo****@tricoequipment.com> wrote in message
news:u6*************@TK2MSFTNGP09.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_**********@mail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.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**********@rogers.com> wrote in message
news:Xn**********************************@127.0.0. 1...
"John 3:16" <bo****@tricoequipment.com> wrote in news:u6p4wefHGHA.344
@TK2MSFTNGP09.phx.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**********@rogers.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**********@hotmail.com> wrote in message
news:u0****************@TK2MSFTNGP11.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. NationalConferencetable 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.EventArgs) Handles MyBase.Load

ReportDataGrid.DataSource = Application ("NationalConferencetable")

ReportDataGrid.DataBind()

End Sub

'sorting code to use headers to sort data.

Private Sub ReportDataGrid_SortCommand(ByVal source As System.Object,
ByVal
e As System.Web.UI.WebControls.DataGridSortCommandEvent Args) Handles
ReportDataGrid.SortCommand

Dim firstView As DataView = New DataView(Application
("NationalConferencetable"))

firstView.Sort = e.SortExpression

ReportDataGrid.DataSource = firstView

ReportDataGrid.DataBind()

End Sub


"John 3:16" <bo****@tricoequipment.com> wrote in message
news:u6*************@TK2MSFTNGP09.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
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...
226
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...
125
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...
3
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 {...
6
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...
6
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...
4
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...
98
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
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...
19
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.