473,670 Members | 2,550 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gridview: Maintain selected checkbox state while Paging

87 New Member
Hi,

I have a gridview with paging option. I want to maintain the state of the checkbox column in gridview for each page.

I used vb.net coding.

I used the following link for this purpose,

http://aspalliance.com/774_Maintaining _State_of_Check Boxes_While_Pag ing_in_a_GridVi ew_Control

It worked properly.

But when i check all the checkbox of page1 in gridview and click the next page, it shows that all checkbox of page2 is checked.

I know the reason for it. Because the index of the gridview row for each page will start from zero only. This causes the problem.

My requirement: I will check 2 checkbox in page1 of gridview and 1 check box in page2. I want to maintain their individual page state checkbox.

Please help me.
Mar 21 '10 #1
2 8646
CroCrew
564 Recognized Expert Contributor
Hello Ananthu,

This can be done. But, first lets have you post what you have done so far and then we can add/edit what you have. This way you get the best fit solution to your question.

Happy Coding,
CroCrew~
Mar 24 '10 #2
Frinavale
9,735 Recognized Expert Moderator Expert
You need to keep track of what has been selected.
You essentially want to keep track of the unique IDs for each row that has been selected. Please remember that you can Sort a GridView and so you can't just keep track of the indexes...you should use some sort of unique identify for each row.

You will need to store this somewhere.
You could store the selected unique IDs in Session, ViewState, Cookies....a HiddenField...w hatever you fancy so long as it is accessible between postbacks.

Every time the user postsback to the server you should update your list of selected unique IDs so that you are always current.

That's pretty much it.

-Frinny
Mar 25 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
3855
by: Paul Hale | last post by:
Hi, Currently using VS2005 c# Scenario: I have a gridview control displaying many items with paging enabled. Column is a checkbox column which users can check, but when the gridview is paged to another page and then back again, the value of the checkbox has been forgotten. Is there a better way of persisting the values through the pages in VS2005 other than writing tedious code behind in the OnPageIndexChanging event? Maybe using the...
1
7005
by: tfsmag | last post by:
Hello, I have a function that returns a dynamically created gridview. This works fine, however it does not seem to be able to maintain state when adding sorting or paging to the gridview. Does anyone have any idea how to get this to work? below is the code. Please bear in mind that the function is actually located in a seperate class file from the page that actually returns the grid. ---code for function that returns the grid, this is...
0
1264
by: Samy | last post by:
Hi There, I have a grid view which has paging enabled in it. One of the colums is a check box and checkbox selections shows a subset of rows a user has selected from available rows. I need to update the dataset by checking the rows selected by a user. What is the best way to do that? I have paging enabled in the gridview and if the user selects some rows in the first page and a few rows in the second page, I save the ids in the...
0
2473
by: Mike P | last post by:
I am trying to edit a gridview while using paging, but whenever I try to edit a row on a page other than page 1, I get an error. Here is my gridview and my code : <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="UserKey" AllowSorting="True" HeaderStyle-Height="24px" AutoGenerateColumns="false" SkinID="Grey3" EditRowStyle-CssClass="dgedit"
3
6588
by: r.hein | last post by:
I've got a middle tier data object that I'm binding a gridview to, and I'm having some problems with the check box, and having it enabled. Let'd start with the middle tier object (and the corresponding collection). The object is simple - it's got some properties (only one has a setter), and a constructor. public class Info { private int _ID; private DateTime _createDate;
9
5531
by: mike7510uk | last post by:
Hi, I am using a gridview with a templatefield containing a checkbox. I want to update the database with a 1 or 0 depending on if a checkbox is checked or unchecked (then use the 1 or 0 later on another page)..i have been google around and found this.... If e.Row.RowType = DataControlRowType.DataRow Then Dim Chk As CheckBox = e.Row.FindControl("CheckBox1") just dont know what to do next...Any ideas?
0
4192
by: =?Utf-8?B?V0I=?= | last post by:
Hi, I have a .NET page which has a gridview of customers from Northwind database. There's a checkbox for each customer and the gridview allows paging. I would like to be able to persist the checkbox status while paging. I'm starting with the code below but I can't get it to work. You can check some of the checkboxes and when you click on the pager, no selection is reflected by the trace. Why's that?
1
3670
by: Neven Klofutar | last post by:
Hi, I have a questin regarding GridView, Template column and Checkbox in it. I'm working on a project that has several "client" applications entering data into DB, and one "admin" application reviewing that data. Since data that admin app can see "must be refreshed in real time", I've created Anthem GridView and AnthemTimer fireing every 5s and rebindind data to GridView every time. GridView has several Bound columnes and 1 template...
2
4745
by: dixonjm | last post by:
I have quite a complicated problem with the above. I will do my best to explain, although I have a word doc (too large to attach here 149KB) with the problem explained full with screen shots if any kind person would like me to email this link too I can do... My Grid View consists of 4 cols:- 1 - ItemTemplate (checkbox) 2 - imageField 3 - ItemTemplate (linkbutton) 4 - ImageField The data that Im binding too consist of nearly 1000...
0
4657
by: sharonrao123 | last post by:
hello all, I have a parent gridview company and in this one a nested gridview people, Is it possible to allow the user to select one row or multiple rows from the people gridview using a check box and also get the datakey (in my case personid) of the the rows selected. Please point me in the right direction. This is what i have so far but i have problem accessing the child gridview in the button click event Cheers, Shilpa. <asp:GridView...
0
8386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8903
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8592
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8661
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6216
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4213
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4393
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2802
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.