473,396 Members | 1,836 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,396 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 1738
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...
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:
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...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...

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.