I am Developing Windows Form Application in .Net, I want to insert selected rows value of Gridview into database. First Column of my GridView is Checkbox, when user check one or more checkbox from gridview, i want to insert values of respective rows into Database.

I am Developing Windows Form Application in .Net, I want to insert selected rows value of Gridview into database. First Column of my GridView is Checkbox, when user check one or more checkbox from gridview, i want to insert values of respective rows into Database.

Try to use this

foreach (DataGridViewRow rw in dataGridView1.Rows)
{
//Ur checkbox verification and insertion of records.
}

that only i want to know,how to check which checkbox is checked.

that only i want to know,how to check which checkbox is checked.

Hi,

foreach (DataGridViewRow rw in dataGridView1.Rows)
            {
                if (rw.Cells[0].Value != null & Boolean.Parse(rw.Cells[0].Value.ToString())==true)
                {

                }
            } 

Just remove that 0 and replace with the column index of that checkbox. This works.

Thank you murugavel.B

i an devloping a web application on e-recruitment..i have to insert the primary key(which is not shown in the gridview but is in the database) checked values of a grid view inside a separate table in the database..please help...i am working on asp.net.

HIDE the key dont show it in gridview !!
if your key is autogenerated then
make it
labelKEY.Visible=false;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.