Persisting row selection in data bound control like GridView,ListView

Some times we need show large amount of data like hundred of rows but its very difficult to show that in a single web page so we are using the paging mechanism of inbuilt data bound control of .NET Framework like GridView and ListView. But in paging  of data bound control its very hard to remember the row selection like suppose you have selected a row in page 1 and then you go to the page2 and return back to page1 the selected row will not be there. So to do that thing you have right custom coding for that. In Microsoft .NET Framework 4.0 there is one property called EnablePersistedSelection which will automatically do that task. It will first introduced on dynamic data support in .NET Framework 3.5 sp1 but its bye default supported by default in .NET Framework 4.0 it self. In earlier version of .net framework the selection was based on row index now its will be based data key for data bound controls. Here is the code for that.

HTML, using GeSHi 1.0.8.8
  1. <asp:GridView id="PersitantGridView" runat="server" EnablePersistedSelection="true">
  2. </asp:GridView>
  3.  
Parsed in 0.006 seconds at 16.01 KB/s

Its based on data key so now you go to page1 and selected third row and then go to the page 2 and selected second row and now you again go to first page and you will have third row selected. That’s it.. Hope this will help you..

Technorati Tags: ,,
Shout it
Published Tuesday, June 22, 2010 12:52 PM by Jalpesh P. Vadgama
Filed under: , ,

Comments

# re: Persisting row selection in data bound control like GridView,ListView

Tuesday, June 22, 2010 3:10 AM by Wesley

Nice tip!

Thanks,

Wes

# Twitter Trackbacks for Persisting row selection in data bound control like GridView,ListView - DotNetJaps [asp.net] on Topsy.com

Pingback from  Twitter Trackbacks for                 Persisting row selection in data bound control like GridView,ListView - DotNetJaps         [asp.net]        on Topsy.com

# Flo et Jason en viennent aux mains ! | Dailymotion

Tuesday, June 22, 2010 10:37 PM by Flo et Jason en viennent aux mains ! | Dailymotion

Pingback from  Flo et Jason en viennent aux mains ! | Dailymotion

# What should I be going after in organic Seo based on my DMOZ? | SEM??????

Pingback from  What should I be going after in organic Seo based on my DMOZ? | SEM??????