[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Gridview get all records across pages

Posted on 2010-08-16
5
Medium Priority
?
728 Views
Last Modified: 2012-05-10
Hi,

I have a data centric application with 1000s of records. I have a gridview retrieving data via an object data source with a page size of 500. There are times when a user wants to access all records across all gridview pages. I made a checkbox in gridview with a default checked, whenever user wants to carry out operations on multiple records (export to excel, add note etc) they just check all rows and perform action. What I realised recently however was that these operations don’t work across gridview pages. My code is as follows:

for (int i = 0; i < gvContacts.Rows.Count; i++)
            {

                CheckBox cbSelectAll = (CheckBox)gvContacts.Rows[i].FindControl("cbSelectAll");

                if (cbSelectAll.Checked)
                {
				//do some action if checked
			}

		}		

Open in new window

So the problem is not to access all records of gridview, the problem is to access all records checked across pages. How could I solve it? Please help.

Thanks.
0
Comment
Question by:oldtedt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 12

Assisted Solution

by:HugoHiasl
HugoHiasl earned 186 total points
ID: 33444094
The advantage of using a paged datasource is that the other data will not be retrieved. The disadvantage is the same :-)

You have only the data for the visible 500 datarows available. If you need to execute operations on all datarows you need to retrieve the id's in the codebehind and store it in a hidden field or directly as javascript variable. If the "check all" is selected the operation needs to use this variable.

But be careful because this can lead to a poor performance if there are to much datarows.
0
 

Author Comment

by:oldtedt
ID: 33444153
isnt there a better way of achieving this?

I am trying to make the paging property of grindview false then bind the data, but problem with this method is the minute i bind data I lose all checked rows and since default is checked they all get checked.

0
 
LVL 16

Expert Comment

by:Kamal Khaleefa
ID: 33444399
there is another method by storing all your data in a session and then bind the session to the grid view
now on each post back save/ update the session with the current values of the grid and the re bind

so by this u keep all the checks in the session
0
 
LVL 12

Accepted Solution

by:
Ramkisan Jagtap earned 189 total points
ID: 33444936
There is also an another way to do it, By storing the selected values of each page into a hidden field. and using them whenever you want.

Regards,
Ram
0
 

Author Comment

by:oldtedt
ID: 33452573
Thanks for all your replies.
There is no straight forward way of achieving this as I was hoping. Even gmail select all button selects all on a page.
Session data was the way I was previously handled this entire grid, but the data is massive anywhere between 500 - 6000 records so I had to remove session variables. All the ways make the performance slower due to data size.

The way I have now tackled this problem is by having different buttons for each action eg.: export all and export selected. 'add note to selected' and 'add note to all'. there is no better way of solving this.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question