Replies Back to Article
Complex Sorting and Paging ASP.Net and DWMX
Charles,
Finally there is someone that can present a ASP.NET tutorial which gives me the 'push' to actually get started with moving to ASP.NET.
Hope you have some more of these tutorials in 'the magic head' covering ASP.NET in DWMX.
Thanks
Great article...i was able to follow it and convert it to VB .Net, if anyone wants the code for this drop me a line.
Cheers,
Stephen
I would greatly appreciate the Vb version of this datagrid sorting tutorial. I emailed you Stephen and I REALLY appreciate you And DMXZone!!!
Thanks,
Charlie stephens
Thanks for the code, there is an alternative method that the folks at Dreamweaver put together using the query string, but this seems to be just as fast, and there is no special coding of the CommandText in the dataset.
For those looking for the VB Version of the code:
'//////////////////////////////////
'Created by: Charles Stratton
'Copyright:2003
'Description: DataGrid ASC/DESC sorting
' Notes: the sort expression on the datagrid should only contain the column name
' e.g sortexpression="EmployeeID"
' and not sortexpression="EmployeeID ASC"
'////////////////////////////////////////////
'Declare Global Variables
Dim strSort As String
Dim strASC As String
Private Sub Sort_Grid(ByVal sender As Object, ByVal e As DataGridSortCommandEventArgs)
strSort = dgEmployees.Attributes("SortExpression")
strASC = dgEmployees.Attributes("SortASC")
strSort = e.SortExpression
dsGrid.DefaultView.Sort=strSort
'Toggle the sort
If strASC ="no" Then
strASC="yes"
Else
strASC="no"
End If
'Update the DataSet sort method and Attribute Carrier
If strASC = "no" Then
dsGrid.DefaultView.Sort +=" Desc"
dgEmployees.Attributes("SortASC")="no"
Else
dsGrid.DefaultView.Sort+=" ASC"
dgEmployees.Attributes("SortASC")="yes"
End If
'Update the DataGrid
UpdateView()
End Sub
Private Sub UpdateView()
'Bind the updated DataGrid
dgEmployees.DataSource = dsGrid.DefaultView
dgEmployees.DataBind()
End Sub
'----------------------------------------------------------------
' Converted from C# to VB .NET using CSharpToVBConverter(1.2).
' Developed by: Kamal Patel (http://www.KamalPatel.net)
'----------------------------------------------------------------
This works well, but after I sort, the edit button calls up the wrong row. Any ideas? Thanks!