Asp.Net News
Free Tech Magazines
Asp.Net Web Hosting
Suggest Us
Link to Us
Feeds Subscription
Questions & Answers
Tips & Tricks
Posted by boda.raju on  6/16/2008 3:29:24 PM Category: ADO.NET
Add to my favorites
Email to friend
iam placed checkbox in gridview if i click on checkbox then press delete button that row delete in database, how is it possible ?
plz send code for that(delete button code)

Post Your Reply Post New Question

 Viewer's Reply
Write delete code in Delete Button Event
Answered By Moderator1 on 6/17/2008 8:43:39 PM

As per my understanding, you want to select the check box in the GridView, then when you click Delete Button, it should delete the rows.

So you have to loop through the GridView rows and find the check box and its corresponding value then perform Delete operation.

The sample code is

protected void BtnDelete_Click(object sender, EventArgs e)
foreach (GridViewRow gvrow in GridView1.Rows)
CheckBox CheckBox1 = (CheckBox)gvrow.FindControl("CheckBox1");
if (CheckBox1.Checked)
// Do all you Delete operations in this block.

You can choose a single check box or you a select multiple check boxes also for Deleting records in your GridView control.

Thanks and have a nice time.
Post Your Reply If you still have problem, post it again under this reply for better response.

Sponsored by
Take Advantage of Oracle's 2 Day DBA Course
Simply JavaScript - Free 150 Page Preview!
Programmers Heaven C# School Book - Free 338 Page eBook