We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,985 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

How to insert selected rows value of Gridview into Database in .net

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.

4
Contributors
6
Replies
2 Weeks
Discussion Span
3 Years Ago
Last Updated
7
Views
mohsinsayyad
Newbie Poster
3 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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.

mohsinsayyad
Newbie Poster
3 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
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

Thank you murugavel.B

mohsinsayyad
Newbie Poster
3 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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.

bekoi
Newbie Poster
2 posts since May 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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

sourabhtripathi
Newbie Poster
22 posts since May 2010
Reputation Points: 0
Solved Threads: 2
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0711 seconds using 2.65MB