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.
}
murugavel84
Junior Poster in Training
53 posts since Apr 2010
Reputation Points: 10
Solved Threads: 8
Skill Endorsements: 0
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.
murugavel84
Junior Poster in Training
53 posts since Apr 2010
Reputation Points: 10
Solved Threads: 8
Skill Endorsements: 0