Complex Sorting and Paging ASP.Net and DWMX

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.


Lets see what it looks like at runtime?

Click F12 on the keyboard or click on the picture of the "world" in the MX menu bar. You should see this:

As you can see Dreamweaver MX has created the paging event for you so now you have a grid with paging!

Thats all good, but we also want to be able to sort the data by the column headings! Well, that was not built into MX like paging . Lets see how we can accomplish sorting:

Sorting the datagrid

In the Dreamweaver environment click the "<>"on the menu bar, also called "code view",  your screen should look like this:

You can see that the datagrid is highlighted in black for you!

Right click on the top line of the datagrid. you should see a link to the "datagrid editor" click it!:

The "DataGrid Editor" should be visible now:

The "DataGrid Editor" contains all of the .Net DataGrid options available. Since we want to be able to sort the datagrid by the column heading then we need to click on "Allow Sorting":

I wish that was it, but its not. We now have to tell (set) each column with what we want it to sort and we have to create the "Event" code to enable sorting. Click on the "Event" "+" in the left hand box you should see a list of Events:

Type "Sort_Grid" into the box of the "OnSortCommand":

In this example we are using C# (It works exactly the same in VB.Net just differing syntax) so in the "OnSortCommand" event of the datagrid we are going to call the SortGrid() function which we will create by hand. Now click "OK". You will see that dreamweaver inserted the event into the code for you:

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 >>

Comments

sorting

December 17, 2003 by Paul Anderson
Excellent article....this has helped me with designing a search results page for my companies website.

Great tutorial !

December 17, 2003 by Marcellino Bommezijn

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

 

 

Thanks - VB .NET examples?

April 1, 2005 by Liam Cassidy
Great article - thank you! I don't use (or know) C#... anyone able to post the VB .NET alternatives?

VB Version

May 12, 2005 by Stephen Davidson

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

See all 9 Comments

You must me logged in to write a comment.