Click here to Skip to main content
15,885,203 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have datagridview in windows application
and is filled with data.
having checkBox coloumn in each row.

I just wanted to save those data rows
which is checked .

How can I achieve this.
Please Assist.
Posted

1 solution

Try this code:
C#
for (i = 0; i <= GridView1.Rows.Count - 1; i++) 
 {
   if (((CheckBox)GridView1.Rows(i).FindControl("chkSelect")).Checked()) 
    {
        GridViewRow row = GridView1.Rows(i);
        valueInCell1 = row.Cells(0).Text;
        //call function to save the data in database...
    }
}


Refer some links;
Selecting multiple checkboxes inside a GridView control[^]
Selecting / Deselecting all the CheckBoxes Inside a GridView[^]
Client-Side Validation for the CheckBoxes Inside a GridView[^]
Maintaining States of Selected CheckBoxes in Different Pages inside the GridView[^]
 
Share this answer
 
Comments
Rahul Rajat Singh 6-Jul-12 1:34am    
good answer. +5
Riyan Oliver 4-Nov-14 1:47am    
superb Rahul its working... & thank you ..

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