Home
Username:
Password:
Microsoft ASP.NET 3.5 Tutorials

ASP.NET & Databases / Sorting & Paging




Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com’s entire library of video tutorials.


Learn More

Subtitles of the Movie

Now I want to show you real quickly about sorting and paging. Sorting is just too cool on these controls and then paging is one of the things; oh, you'll love it or hate it. Let's start off with sorting. When I run this data, I've got my grid view. I really haven't changed anything. I've got a grid view here and I've hooked it to the PUBS database. You can hook it to any database. But notice everything's down through here but what order is this data in? Well, it doesn't appear to be in any particular order. It would be really cool if I could sort this. Well, how much code would I have to write to be able to re-sort this data? Well, I'll show you. Here's how much code I'll have to take care of. A click on this little button, I click on my Grid View, I then click on this little arrow sticking out here and check this: Enable Sorting and I'm done. Now I'm going to rerun this without debugging and I want you to see what's going to happen here. I now have these hypertext links at the top of every column and if I want to see this in last name order, I just click that and there it is in ascending order. I can put it in state ascending order and if I click it again, then it goes into descending order. So here's the first name in ascending order or I can see it in descending order. Here's my ids in ascending order. Look at all those social security numbers, right? But how cool is that? Now, that gets me all of my information in whatever order that I want it to do and a lot of end users will like this because they can actually use this as a tool to find things. Now, this is one of those things where, you know, people will ask you wow, how did you do that? I say, well, it's just a little code I wrote up, you know, one night when it was getting kind of late and I thought I'd knock this out real quick, you know. You can kind of pat yourself on the back a little bit there if you can live with yourself that way. The next thing I want to show you is paging. Now, some people love this and some don't. It can confuse the end user sometimes, depending on their users. But notice to enable paging you've already guess it; just click Enable Paging here and what it's going to do is it's going to limit the number of lines that I see on the page and it makes it not take up so much room on the page and you're going to notice that I now have these hypertext links at the bottom. And it's divided my data into three pages and if I click this, I will see the second page of the data that came back from the database. Then if I click this I see the remainder that came back. I can still sort, just like before, OK? It took me back to Page 1, there's Page 2 sorted by first name. I can click on Last Name and re-sort. It takes me back to Page 1. So paging can be somewhat irritating. I tend to not like paging. I would rather see all the data and then I can use it and I'd rather scroll up and down. Other people feel strongly and a lot differently about that but I wanted you to see how you can be sorting and paging on these controls and a lot of these controls will have the same type options and so forth. So what you've seen in these last two or three videos is how to make data appear on the Web page, how to get where you can edit it and delete it and then I'm going to do one more video and talk just a little bit about some of the other controls and what you can do with them but this should get you going and give you some really good ideas on how to use data and again, I want to remind you; if you'll jump out there and start to work with ADO.NET, the sky is the limit and I would strongly recommend that you go grab some third-party books out in the bookstores or on Amazon and look around on Microsoft's site, go out and Google. There's all kind of cool tips and tricks and things that you can do back here in the source code. You can make some incredible changes to these things just really quick. That's a good run-through on the grid view, on sorting, paging, editing and all that stuff just in three or four videos here, so good luck with it.

Tutorial Information

Course: Microsoft ASP.NET 3.5
Author: Mark Long
SKU: 34102
ISBN: 1-93633412-7
Release Date: 2010-03-24
Duration: 6 hrs / 69 lessons
Work Files: Yes
Captions: Available on CD and Online University
Compatibility: Vista/XP/2000, OS X, Linux
QuickTime 7, Flash 8

VTC Sign up & Benefits

  • Unlimited Access
  • 98,729 Video Tutorials (23,265 free)
  • Video Available as Flash or QuickTime
  • Over 1026 Courses
  • $30 for One Month Access
  • Multi-User Discounts Available