Complex Sorting and Paging ASP.Net and DWMX
by Charles Stratton

When I started programming I would scour the internet for good examples of code, You usually end up writing most yourself. I began programming <html> in 1999 and used notepad until I found out about Dreamweaver and Visual Studio and then I went crazy making sites. This article will teach the advanced and Intermediate users the great WYSIWYG of the Dreamweaver environment and the power of MX and .Net with a little homemade code to make it all come together for Complex ASP.Net Datagrid ASC/DESC sorting and paging.

Complex Sorting and Paging

with ASP.Net and Dreamweaver MX

You should be familiar with:

1.      Dreamweaver Ultradev or MX environment (creating files,panels etc..)

2.      SQL Server or Access Database available

3.      Can read ASP, VB, or C type language

You should have:

1.      A site setup for ASP.Net (C#.NET for C users, and VB.NET or ASP users) in Dreamweaver MX

2.      Create a new file called sort.aspx

Step 1

Create the Database Connection

The Northwind Database (comes installed with ms access and ms sql server). If the "Application" panel is not on the screen then on the menu bar go to: "Window" then click "database". The "Application" panel will be visible. On the "Application" panel click the "+" sign. You will see two options: OLE DB Connection and SQL Server Connection. Since we will be connecting to the local sql server click "SQL Server Connection". If you do not have sql server click "OLE DB Connection" you can still do the example with Access. The only difference will be the connection properties in the page and the connection string.

Now the Connection Box will be visible:

Type in the following connection string:

If you are on a secure network then type your computers workstationid (computers name) at the end of the string:

Also, when you setup sql server if you supplied a username and password then include them in the connection string.

Now click the "Test" button. You should get this box confirming the connection.

Note: you cannot go on if this box does not come up. If you get an error message something is wrong with the connection string.

Now in the application panel the Northwind database will be visible and ready to start using in the MX environment:

Charles Stratton

Charles StrattonI enjoy programming and someday plan on writing a book. I have been developing Enterprise web applications since 1999.

See All Postings From Charles Stratton >>

Place your comment about Complex Sorting and Paging ASP.Net and DWMX

You must me logged in to write a comment
You can convert the VB.Net to C#
May 28, 2007 by david crook
If you want an industrial strength way to convert VB.Net to C# and the free converters just don't cut it, check out
March 12, 2007 by cherie reinheimer
Great Tutorial! don't for get the -script- tags for the vb code!
edit after sort
December 18, 2006 by Ted Matson

This works well, but after I sort, the edit button calls up the wrong row.  Any ideas?  Thanks!

Great way to sort
August 30, 2005 by ERP ERP

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
 '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
 'Toggle the sort 
   If strASC ="no" Then
   End If
 'Update the DataSet sort method and Attribute Carrier
  If strASC = "no" Then
   dsGrid.DefaultView.Sort +=" Desc"
  dsGrid.DefaultView.Sort+=" ASC"
  End If
   'Update the DataGrid
End Sub
Private  Sub UpdateView()
 'Bind the updated DataGrid  
 dgEmployees.DataSource = dsGrid.DefaultView
End Sub

' Converted from C# to VB .NET using CSharpToVBConverter(1.2).
' Developed by: Kamal Patel (

See all 9 Comments