Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two gridviews 1. grid1 , 2.grid2..
grid1 contains one textbox column and second checkbox column...if i check the checkbox from grid1 corresponding values add to grid2...if uncheck the checkbox from grid1 the corresponding values remove from the grid2...
for example:

Grid1:

Item Checkbox
----- ---------
Soap "
Electronics "

if i check the soap and Electronics the values add from the database to grid2...

Grid2:

SubItems
--------
Dove
Pears
CD/DVD
LCD/LED

If i uncheck the Electronics It should be show like this:
SubItems
--------
Dove
Pears
Posted

1 solution

C#
//Put the timer and write this below loop into the timer

for (int j = 0; j < grid1.Rows.Count; j++)
{
    if (grid1.Rows[j].Cells[0].Value != null)
    {                                
        Boolean b1 = (Boolean)grid1.Rows[j].Cells[0].Value;
        if (b1 == true)
        {
            //Here you can add the value to the second grid
            //if (b1==true) add the value to the second grid
            //if (b1==false) remove the value from the second grid
            
            //The important thing is, when you add the value to the second grid you should add the values soap and electronics also in the second grid. it should be in the another column and that column should be in visible = false
            
            //Based on this column you can remove the items when the checkbox is unchecked from the grid1
        }       
    }                          
}
 
Share this answer
 
v2
Comments
Member 10339067 28-Feb-14 1:27am    
if i check soap it adds to grid2: first column like dove,pears and second column is soap then how to delete from the grid2...
Member 10339067 28-Feb-14 1:28am    
i need the coding for remove the values from grid2
Mathan Sivanantham 28-Feb-14 1:55am    
In grid1, will you check only one check box or more at a time?
Member 10339067 28-Feb-14 2:57am    
more checkbox
Mathan Sivanantham 28-Feb-14 3:10am    
So you will check soap and electronics in same time, and the corresponding values should come in the grid 2.,

and the grid 2 column should be like this.,

Dove Pears CD/DVD LCD/LED

Right?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900