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


Top 5 Contributors of the Month
david stephan

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?

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

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

http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/1dd3aaa6-cf23-4671-aba5-569276e1f207/

Thanks
Priya

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);
MessageBox.Show(str);

// Here your Insert Code
}


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

// Here your delete Code
}

}




Regards, Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/


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
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

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