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.
Persisting Row Selection in Data Controls is a new feature in ASP.NET 4 that you're going to hear about and probably read quite a bit about and to understand it, I want to first tell you how things used to be and we're talking about Row Selection. When you've got a Grid View or, or you know, any kind of Data Control on a page and the user selects a row, some interesting things can happen especially in previous versions of ASP.NET because the Row Selection was based on the row index on the page and so here's what would happen. If you were on page 1 in, in a Grid View and you selected the third item or the third row on the page and then you moved to page 2, the third item on page 2 would already be selected and you're thinking, wait a minute, who thought this was a good idea. And it could create some issues and some errors if your end-users were trained or weren't paying attention or if you didn't write some code to correct that problem. Now this was handled in the .NET framework, 3.5 release with Service Pack 1, it did provide Persisted Selection but in, only in Dynamic Data Projects and so what they've done here is they've kind of cleaned it up a little bit more. ASP.NET 4 now provides Persisted Selection on two Data Controls. That is the Grid View Control and the ListView Control. So now what's happened is, Selection State is based on the items Data Key and so they've changed the way their pointing to this and keeping up with Selection State and so now here's what happens with the new functionality and you can actually turn this on and off and I'll show it to you in just a moment out in the Visual Web Developer. So with the new functionality, so you go out there, you open a Grid View, you get some data in it and you select row 3 on page 1, then you move to page 2. Guess what? Nothing is selected. Then you go back to page 1 and row 3 is still selected there. This is the way you think would work, this is the way you anticipate that it would work. So now let's jump out to the Visual Web Developer and notice I've just got a basic old website opened up here, but what I want to show you is, is that if I go to my Data Controls, in the Toolbox and I grab a Grid View and just drop it on here somewhere, doesn't matter where, notice as soon as I drop that on, as long as I click on it here in my Properties over here, I can scroll up just a little bit and you will see right here, Enable Persisted Selection. Now if I scroll this to the left, you can read it and notice that it's set to False and I can set that to True and notice down here in the description, this is going to toggle whether the selection should be based on Data Keys or on Row Index. We want it on Data Keys so that if we set it True, so that it will persist the Row Selection when we run this thing. Okay. Now that's going to happen for ListView as well. Now you can't see it here but you can also see on the Source here, I can go to Grid View and there is the Enable Persisted Selection Attribute that I can set to true or false if I want to do it back here in the Source Code. Let me make all this stuff go away and you can see it a little better and so right there's my Grid View Control and there is my Enable Persisted Selection Attribute. So this is some really, really nice functionality, we've only got it on two Data Source Controls but that's a good place to start and as we see more controls develop and more things. Now keep in mind in some third party controls out there you could get this stuff preprogrammed in but we're talking about the controls that are packaged within ASP.NET 4 and again that's all you're probably going to be tested on. There's no probably to it, that's all you're going to be tested on. Microsoft's not going to jump out into third party controls and start testing on those. So anyway, that is the ability to Persist Row Selection in Data Controls. Watch for this, to pop up in some form on the exam.
| Course: | Designing and Developing ASP.NET 4 Web Apps (Exam 70-519) |
| Author: | Mark Long |
| SKU: | 34292 |
| ISBN: | 978-1-61866-029-9 |
| Release Date: | 2011-12-31 |
| Duration: | 8.5 hrs / 108 lessons |
| Work Files: |
Yes |
| Captions: | No |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |