Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > ASP.Net Datagrid sort

Reply
Thread Tools

ASP.Net Datagrid sort

 
 
George Zolla
Guest
Posts: n/a
 
      12-06-2003
I can sort the contents of a datagrid using the following code but when I
change to another page in the dataset I lose the sort. How do I sort the
dataset and keep it when I go to a new page?

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

Dim DataView1 As New DataView(DsTerritories1.Territories)

DataView1.Sort = e.SortExpression

DataGrid1.DataSource = DataView1 'need this to rebind grid

DataGrid1.DataBind()

End Sub

Here is the paging code:

Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEvent Args) Handles
DataGrid1.PageIndexChanged

'need to rebind the datgrid to the source after the page is changed

'However if a sort is performed before the page change the sort is lost

'Need to have dataview with scope for entire project to correct this.

DataGrid1.CurrentPageIndex = e.NewPageIndex

DataGrid1.DataSource = DsTerritories1.Territories

DataGrid1.DataBind()

End Sub




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: When will Thunderbird support sort in place (in context sort)? Ron Natalie Firefox 0 02-02-2006 04:38 AM
The Colourised Bewitched -- sort of OK....... sort of! anthony DVD Video 26 06-28-2005 04:39 AM
DataGrid. How to keep the right keyfield value when Sort the DataGrid? Eugene ASP .Net 0 09-28-2004 05:15 PM
xsl:sort lang="es" modern vs. tradidional Spanish sort order nobody XML 0 06-01-2004 06:25 AM
Ado sort error-Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. Navin ASP General 1 09-09-2003 07:16 AM



Advertisments