Write delete code in Delete Button Event |
|
Posted By
Moderator1
on
6/17/2008 8:43:39 PM |
|
|
|
Description: |
Hi,
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)
{
//Response.Write("Deleted");
// 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. |
|
|
|