Udostępnij za pośrednictwem


PersistedSelection in Data Controls in .NET 4

We did a variety of small feature items across the data controls when we were working on .NET 4 and I’m going to do a couple of blog posts on some of this new functionality. When we were building Dynamic Data we made small enhancements to the data controls but they only worked when you were using Dynamic Data. In .NET 4 we took this functionality and made it work across all of our core data controls.

Persisted Selection

When using our data controls that support paging like GridView and ListView there is some funky behavior today. If the user selects the first row of data and then moves to the next page the first row of the data is selected. This behavior seems weird, especially when you are in a master detail scenario where you show the details of the selected row on the same page. As you page through your data the detail view would keep changing as you move from page to page. Here is what the old behavior looks like:

image      

You can see in the first image that the second row is selected.

image

As I move to the second page the second row which is a different user is selected. This is probably not what a user would expect when using the controls. Now I’m going to enable a new property on the control called EnablePersistedSelelection and set it to true.

    1: EnablePersistedSelection="true"

And now we can look and see what the behavior looks like:

image     

You can now see that I select Scott Hunter in the first page.

image

And move to the second page and no row is selected.

image

but moving back to the first page Scott Hunter is still selected. This should make master / detail view work better we think this is the behavior that someone would expect when using the control anyways.