473,385 Members | 1,453 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.

sorting and paging

Hi,

I'm using a datagrid to display contents of a dataset and I've set the
datagrid to allow paging and sorting.
Rather than re-retrieve from the DB, I store the original dataset in a
Session variable and then rebind to it for each page (which works).
I'd also like to be able to sort any of the columns of the datagrid, so I do
this using a dataview as shown below triggered from the normal
Grid_SortCommand event :

Private Sub ResultGrid_SortCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridSortCommandEvent Args) Handles
ResultGrid.SortCommand
Dim ds As DataSet
ds = Session("myRecs")
Dim dv As New DataView
dv = ds.Tables("myTable").DefaultView
dv.Sort = e.sortExpression
ResultGrid.Datasource = dv
ResultGrid.DataBind()

' store sorted dataset in session ????
End Sub
The above sort works but when I click on my datagrid page links, it loses
the sorting when the page returns.
It tried storing the sorted dataview as below, but it didn't work

Dim dt As DataTable
dt = dv.Table.Copy()
ds = New DataSet(dv.Table.TableName)
ds.Tables.Add(dt)
Session("myRecs") = ds
Any ideas how I can retain sorting and paging together ???

Thanks
Dave
Jul 21 '05 #1
1 1736
Don't know if anyone's looked at my post below, but no need to bother now
I've figured out a way of doing it.
I saved the sortExpression in the session along with the dataset, if a
sortexpression existed in the session, I loaded the dataset into a dataview
and re-applied the sortexpression and paging was automatically applied along
with the correct sort order.
"Dave S" <da********@hotmail.com> wrote in message
news:bb******************************@news.teranew s.com...
Hi,

I'm using a datagrid to display contents of a dataset and I've set the
datagrid to allow paging and sorting.
Rather than re-retrieve from the DB, I store the original dataset in a
Session variable and then rebind to it for each page (which works).
I'd also like to be able to sort any of the columns of the datagrid, so I do this using a dataview as shown below triggered from the normal
Grid_SortCommand event :

Private Sub ResultGrid_SortCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridSortCommandEvent Args) Handles
ResultGrid.SortCommand
Dim ds As DataSet
ds = Session("myRecs")
Dim dv As New DataView
dv = ds.Tables("myTable").DefaultView
dv.Sort = e.sortExpression
ResultGrid.Datasource = dv
ResultGrid.DataBind()

' store sorted dataset in session ????
End Sub
The above sort works but when I click on my datagrid page links, it loses
the sorting when the page returns.
It tried storing the sorted dataview as below, but it didn't work

Dim dt As DataTable
dt = dv.Table.Copy()
ds = New DataSet(dv.Table.TableName)
ds.Tables.Add(dt)
Session("myRecs") = ds
Any ideas how I can retain sorting and paging together ???

Thanks
Dave

Jul 21 '05 #2

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

Similar topics

0
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update...
2
by: Hajime Kusakabe | last post by:
Hi. I have created a datagrid (datagrid1) without any columns on a aspx page. Then aspx.vb adds columns from a database. It is somthing like this .... ================================== Dim...
1
by: Guoqi Zheng | last post by:
Sir, The default paging of datagrid is somehow use too much resource, so I am using Stored procedure for the paging. You can find my Stored procedure at the end of this message. It works...
2
by: saleek | last post by:
Hi, I am trying to figure out why my datagrid has stopped firing the page and sort commands. Scenario: I originally had template columns in my datagrid and had set up custom bi-directional...
1
by: Dave S | last post by:
Hi, I'm using a datagrid to display contents of a dataset and I've set the datagrid to allow paging and sorting. Rather than re-retrieve from the DB, I store the original dataset in a Session...
5
by: LDD | last post by:
Hi Folks I'm trying to determine a way to handle paging, filtering and sorting in a datagrid. If I choose to filter and sort, I'd like to return a subset. If that resultset has more records...
2
by: Kuldeep | last post by:
Hi All, I have been trying to find some algorithms for datagrid sorting and paging. Please help Regards Kuldeep
0
by: Roy | last post by:
Hey all, I must be losing my touch. I have made many pages in the 1.1 framework that utilize custom bidirectional paging in datagrids. We've converted over to 2.0 and I've been trying to use the...
1
by: John A Grandy | last post by:
In regard to a GridView that must support searching, filtering, sorting, and paging ... There is a tradeoff in performing the sorting and paging in the database versus to creating a CLR sort...
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: 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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.