Click here to Skip to main content
15,909,827 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

The idea is to have a button which when clicked, a loop will be executed over GridView Rows.
Within the loop we will check whether the CheckBox for that row is checked,
if the CheckBox is checked then the Value from the GridView Rows that are checked
will be fetched and inserted into database table.
i am using 3 layered architecture.
please help.
Thanks.
Posted
Comments
Kornfeld Eliyahu Peter 26-May-14 9:03am    
What have you done so far? Show some effort (code or search)! As is it ain't a question...

Hi, here is how you can check if the checkbox is selected or not


C#
foreach (DataGridViewRow row in dataGridView.Rows)
                {
                    //we check if the cell number 5(the checkbox) is checked or not 
                    if (Convert.ToBoolean(row.Cells[4].Value) == true)
                    {
                        //here you can do your save in database operation
                    }
                }


I personllay hate working with datagrid data directly.

I always save my data in a list and then put that data in the datagrid.

Operation will be much easier, and the possibilites to make error is minor.

If you don't have a checked properties in your class object, then you can manage to add a neww properties using inheritence(create a new class that inherit from your main class and add a booleen prop for checked items)

Hope it helps
 
Share this answer
 
 
Share this answer
 

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