.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Easy Web
Imran Ghani

Home >> Forum >> ADO.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Deleting records from database while deselecting checkbox in gridview

Posted By: sarada     Posted Date: December 13, 2011    Points:5   Category :ADO.Net
I have a gridview that contains checkboxes.If I click few checkboxes, I am able to insert data into database.

Now, when I am deselecting the same checkbox which was selected earlier, I want that data should be deleted from database.What is the C#.net code to do it please?

Author: priya             
Posted Date: December 15, 2011     Points: 20   

You can follow this thread to delete gridview selected row from checkbox to database



Author: Narayanan             
Posted Date: January 18, 2012     Points: 20   

Hi Sarada,
I think, It may be useful to you.
Button Click Event:
    foreach (DataGridViewRow row in dataGridView1.Rows)

if (Convert.ToBoolean(row.Cells["Column1"].Value) == true)
string str = Convert.ToString(row.Cells["Column2"].Value);

// Here your Insert Code

else if (Convert.ToBoolean(row.Cells["Column1"].Value) == false)
string str = Convert.ToString(row.Cells["Column2"].Value);

// Here your delete Code


Regards, Lakshmi Naraayanan.S

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend