asp.net - Persist checkbox in gridview while custom paging -


i have created gridview , added checkbox in item template. grid has few columns along datakey (primary key). due performance gain, grid fetch next set of recrods on each page change based on page number click. done.

now when user selects checkbox in page 1 , go page 2 , coming page one, user not see checkbox checked user did earlier.

so there way persist checkbox when user move page page?

this checkbox used flag select rows can deleted later button outside grid.

since receive new set each time paging selected, suggest following approach:

create array[] object via javascript add list datakey whenever checkbox selected , in turn remove if checkbox deselected. this:

var selecteddatakeys = [];  $('.checkboxclass').on('change', function() {     // considering assign data key id checkbox otherwise implement way retrieve id.    var datakey = $(this).prop('id');     // determine if datakey in selected data keys array    var iscontained = (selecteddatakeys.indexof(datakey) > -1 );     if($(this).is(':checked')) {       // if contained false - add array       if (!iscontained)          selecteddatakeys.push(datakey);    } else {       // if contained true - remove array       if (iscontained){          selecteddatakeys = $.grep(selecteddatakeys, function(value) {             return value != datakey;          });       }    } }); 

from point on client user have active list of selected items, use list manipulate grid display page. either modify display on document ready comparing item on grid display selecteddatakeys array or sending keys , comparison server side.

hope helps.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -